1. Dynamically modify the color value of the solid attribute of Shape
Usually we often use Shape in xml, and the same Shape may be used in development, but the color and background color are different.
//比如:
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<corners android:radius="5dp" />
<solid android:color="@color/white" />
</shape>
Solution:
//我们在Activity中去动态修改背景颜色,就不需要重新再写一个shape了。是不是很方便
GradientDrawable drawable =(GradientDrawable)view.getBackground();
drawable.setColor(getResources().getColor(color));
2.Android studio creates a new project and has been building to solve
The main reason may be that the version of your Android studio does not correspond to it, or it is blocked. As a result, the version of gradle cannot be downloaded , so it has been building
First find the file package address:
C:\Users\Administrator.gradle\wrapper\dists
This is my address, you can find your corresponding address
The solution is to find your new project
Modify the parameters inside: distributionUrl=…
#Fri Jan 06 12:40:33 CST 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip
Remember the premise is that your gradle-2.10-all file is not empty, otherwise you still need to wait for building .
Another way is to go to (https://services.gradle.org/distributions) to download the same version of gradle and put it in the path: C:\Users\Administrator.gradle\wrapper\dists folder.
Maybe after you complete the modification, the following error will be reported again,
Gradle sync failed: Another 'refresh project' task is currently running for the project: C:\Users\Administrator\Desktop\Deyijia1
Consult IDE log for more details (Help | Show Log)
Then let's close Android studio directly and find log log. delete all
3. The solution to the unmappable character of GBK incorrectly encoded during JNI compilation
The reason for this error is that the JDK is an international version. When compiling, if we do not use the -encoding parameter to specify the encoding format of our JAVA source program, javac.exe first obtains the encoding format adopted by our operating system by default. .
Solution: You should use the -encoding parameter to specify the encoding method, such as:
javah -jni -encoding UTF-8 com.example.XXXX.XXXX.MainActivity
4. Youmeng WeChat payment jar conflict
If you use the simplified version of WeChat, there is no payment-related content. If you want to add payment, just delete the jar of umengwx (keep weixin2), and put it into the native jar of WeChat. If you are using the full version of WeChat, the weixin1 jar is the same jar as the WeChat native sdk (just with a different name), so in order to ensure the same version, please use the weixin1 jar and delete the WeChat native sdk to realize payment.
Reason: libammsdk.jar and SocialSDK_WeiXin_1.jar contain the same a.class file in both packages.
Error code:
Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'.
> com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/tencent/mm/opensdk/a/a/a$a.class
The above paragraph is the solution of Youmeng, which looks a bit blunt
NOTE: I am using the full version . The two jar packages libammsdk.jar and SocialSDK_WeiXin_Full.jar were used , and the original SocialSDK_WeiXin_1.jar and SocialSDK_WeiXin_2.jar packages were deleted, causing the WeChat payment call to fail.
The final solution is to keep using SocialSDK_WeiXin_1.jar, and the two packages of SocialSDK_WeiXin_Full.jar will not conflict. All other old version packages are removed.
5. [Android] WebView loading https pages cannot display resources normally
Jump to this address: http://blog.csdn.net/crazy_zihao/article/details/51557425
6. ImageView (fitXY) property
The effect of the display method of fitXY is: according to the size set by ImageView, the image is stretched to fill the space, and (when this property is set alone) the image will be deformed.
adjustViewBounds is to limit the image to maintain the original image ratio when displayed. (Combined with fitXY display mode can achieve adaptive effect)
7.java.lang.IndexOutOfBoundsException: Inconsistency detected. Invalid item position
java.lang.IndexOutOfBoundsException: Inconsistency detected. Invalid item position 157(offset:157).state:588
at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:3300)
at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:3258)
at android.support.v7.widget.LinearLayoutManager$LayoutState.next(LinearLayoutManager.java:1803)
at android.support.v7.widget.LinearLayoutManager.layoutChunk(LinearLayoutManager.java:1302)
at android.support.v7.widget.LinearLayoutManager.fill(LinearLayoutManager.java:1265)
at android.support.v7.widget.LinearLayoutManager.scrollBy(LinearLayoutManager.java:1093)
at android.support.v7.widget.LinearLayoutManager.scrollVerticallyBy(LinearLayoutManager.java:956)
at android.support.v7.widget.RecyclerView$ViewFlinger.run(RecyclerView.java:2715)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:725)
at android.view.Choreographer.doCallbacks(Choreographer.java:555)
at android.view.Choreographer.doFrame(Choreographer.java:524)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:711)
at android.os.Handler.handleCallback(Handler.java:615)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4921)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1027)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:794)
at dalvik.system.NativeStart.main(Native Method)
8. Regarding the use of recycleview, the Item layout is higher and the layout problem of incomplete display.
I checked it later, mainly because the outermost layer of the layout android:layout_height="match_parent" uses this attribute, which causes only one screen to be drawn while drawing . We will layout the outermost attribute **android:layout_height="wrap_content"** so that there will be no problem of incomplete drawing.
9.Translation1.3.6 Configure application ID and application key
- Log in to http://ai.youdao.com, then register and log in to your account.
- Find application management - my application - create application
- The time to witness the miracle has come, and there are two pictures when you shake your hands
It's time to work next, so I don't need to say more.
#Error:(176, 13) Failed to resolve:
**The general reason for this situation is that there is a problem with the referenced download address, and the gradle cannot be found. **So we need to directly change the maven address of the build.gradle file.
repositories {
jcenter()
// maven {
// url 'http://maven.aliyun.com/nexus/content/groups/public'
// }
maven {
url 'https://maven.google.com/'
}
}
10. java.lang.NoClassDefFoundError appears: below Android 5.0
The reason is: because the number of project methods exceeds the limit of dex breaking 65535 .
We turned on multiDexEnabled true , but did not initialize MultiDex.install(base) in the Application , resulting in an error. Add this method in the Application class .
@Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
MultiDex.install(base);
}
Solution: https://www.jianshu.com/p/8b4f711da0bb
11. Internal java.lang.NoClassDefFoundError: Failed resolution of: Lcom/ta/utdid2/device/UTDevice
If you use Youmeng SDK, you can check if there is no imported package
compile 'com.umeng.sdk:utdid:1.1.5.3'
The way of writing after Android Studio 3.0 is
implementation 'com.umeng.sdk:utdid:1.1.5.3'
If the error is still reported, there may be a conflict with Ali's package. Solution
Please jump to: https://help.aliyun.com/knowledge_detail/55956.html
12. Youmeng Device_token can not be obtained related issues [Android version]
Solution:
Please jump to: http://bbs.umeng.com/thread-15233-1-1.html
13.cannot find implementation for WordRoomDatabase. WordRoomDatabase_Impl does not exist
problem lies in:
- Does the project use kotlin ?
If so, please check whether the build.gradle file is correct
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
//apply plugin: 'kotlin-kapt'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.zy.wanandroid"
minSdkVersion 21
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.android.support:design:28.0.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation 'com.android.support:recyclerview-v7:28.0.0'
implementation 'io.reactivex.rxjava2:rxjava:2.2.3'
implementation 'io.reactivex.rxjava2:rxandroid:2.1.0'
//主要就是这三个,你要看是否一致,使用是否正确,如果你使用了kotlin 三个缺一不可
implementation "android.arch.persistence.room:runtime:1.1.1"
//注意看 后缀还不一样 room:compiler
annotationProcessor "android.arch.persistence.room:compiler:1.1.1"
kapt "android.arch.persistence.room:compiler:1.1.1"
implementation 'android.arch.lifecycle:extensions:1.1.1'
implementation "android.arch.navigation:navigation-fragment:1.0.0-alpha07"
implementation "android.arch.navigation:navigation-ui:1.0.0-alpha07"
}
14. io.reactivex.exceptions.UndeliverableException: The exception could not be delivered to the consumer because it has already canceled/disposed the flow or the exception has nowhere to go to begin with. Further reading: https://github.com/ReactiveX/RxJava/wiki/What’s-different-in-2.0#error-handling | kotlin.NotImplementedError: An operation is not implemented: not implemented
Solution: https://blog.csdn.net/lmh820822/article/details/76854411
15. java.lang.RuntimeException: Unable to start activity ComponentInfo{xxxActivity}: java.lang.IllegalStateException: Only fullscreen opaque activities can request orientation
Cause Analysis For
targetsdk26 and above, the android:screenOrientation cannot be set through the manifest for activities with transparent themes.
For specific analysis, see
https://zhuanlan.zhihu.com/p/32190223
Solution
Check whether the Activity that reported the error has declared android:screenOrientation in the AndroidManifest, and remove it if necessary.
16. OKHttp exception java.lang.IllegalStateException: pits encountered during closed and debug
Solution address: https://blog.csdn.net/u012587005/article/details/78504925
17. Android multi-language switch, adapt to 8.0
Solution address: https://www.jianshu.com/p/f56e30b6f631
The specific reason is that if the system is above 8.0, it needs to use the context of Activity.
18.android Typeerror:Cannot read property ‘xxxx’ null
Solution address: https://www.e-learn.cn/content/wangluowenzhang/651768
19.Expected Android API level 21+ but was 19
Check if your version of Okhttp is changed from
implementation 'com.squareup.okhttp3:logging-interceptor:3.14.0' to
implementation 'com.squareup.okhttp3:logging-interceptor:3.12.0' and you need to downgrade the version
20. Android studio terminal git log garbled problem solution
terminal input: set LESSCHARSET=utf-8
21. java.lang.IllegalArgumentException: Parameter specified as non-null is null: method kotlin.jvm.internal.Intrinsics.checkParameterIsNotNull, parameter favicon
Solution: https://blog.csdn.net/jia635/article/details/81068866
22. Application signature claim
jarsigner -verbose -keystore [ key file path ] C:\sign_verification\mykeystore -signedjar [ package name and path after packaging ] meizu.apk [ unsigned package name ] meizuemptyapk-release-unsigned.apk [key Alias] meizu
23. AndroidStudio does not display New Flutter Project
Solution: https://www.jianshu.com/p/ebaf065d7b1c
24. Android 9.0 installation package parsing error
Solution: https://blog.csdn.net/keep_my_mine/article/details/101025819
25. WebView, the second call to loadUrl does not refresh the page
Solution: https://blog.csdn.net/qq_26225663/article/details/100557671
26. Google application market replacement key scheme
https://support.google.com/googleplay/android-developer/contact/otherbugs
Communicate with customer service and wait for Google's official reply email. The content is as follows
Export the certificate of the key to PEM format:
keytool -export -rfc -alias upload -file upload_certificate.pem -keystore keystore.jks
After executing this code, the PEM file can be produced. Send it to the official Google mailbox and it will be OK
27. Android Missing permission to insert badges permission crash
The situation is also quite strange, only the Sony model has this permission error prompt, after various searches, it is finally found that some special model permissions need to be added in AndroidManifest.xml. Closer to home, as follows:
<!-- START: ShortcutBadger -->
<!-- Samsung -->
<uses-permission android:name="com.sec.android.provider.badge.permission.READ"/>
<uses-permission android:name="com.sec.android.provider.badge.permission.WRITE"/>
<!-- HTC -->
<uses-permission android:name="com.htc.launcher.permission.READ_SETTINGS"/>
<uses-permission android:name="com.htc.launcher.permission.UPDATE_SHORTCUT"/>
<!-- Sony -->
<uses-permission android:name="com.sonyericsson.home.permission.BROADCAST_BADGE"/>
<uses-permission android:name="com.sonymobile.home.permission.PROVIDER_INSERT_BADGE"/>
<!-- Apex -->
<uses-permission android:name="com.anddoes.launcher.permission.UPDATE_COUNT"/>
<!-- Solid -->
<uses-permission android:name="com.majeur.launcher.permission.UPDATE_BADGE"/>
<!-- Huawei -->
<uses-permission android:name="com.huawei.android.launcher.permission.CHANGE_BADGE" />
<uses-permission android:name="com.huawei.android.launcher.permission.READ_SETTINGS" />
<uses-permission android:name="com.huawei.android.launcher.permission.WRITE_SETTINGS" />
<!-- End: ShortcutBadger -->
28. Android-Device supports x86,but APK only supports armeabi-v7a,armeabi,x86_64
Solution: https://blog.csdn.net/qq_34476727/article/details/74910379
29. java.io.FileNotFoundException: /storage/emulated/0/
The specific reason is that because the current project uses the Android Q version, the corresponding version number is 29. There is this BUG
solution: https://www.jianshu.com/p/3159f2c5b2a1
30. android 10 Permission denied
Solution: https://blog.csdn.net/wuqingsen1/article/details/104752459/
31. Android Studio real machine wireless debugging
Tutorial: https://www.cnblogs.com/chenlove/p/12327964.html
32.Android11 application-side adaptation points
https://juejin.im/post/6890811621724618765
33.Android studio updating symbols
https://stackoverflow.com/questions/39640433/android-studio-2-x-building-symbols-forever
-Xms256m
-Xmx8192m
-XX:ReservedCodeCacheSize=2048m
-XX:+UseCompressedOops
-XX:MaxPermSize=4096m
Click "help" - "Edit Custom VM options" to add the above code,
mainly because the android studio running memory allocation is insufficient, and the loading is too
slow``
34. On the Android side, arouse the QQ temporary chat window
val urlQq = "mqqwpa://im/chat?chat_type=wpa&uin=输入QQ号&version=1&src_type=web&web_src=oicqzone.com"
val intent = Intent(Intent.ACTION_VIEW, Uri.parse(urlQq))
startActivity(intent)
35.[SSI10004] Weibo share webpage (WebPage) type, the link is only displayed as the text of "Webpage Link" in Weibo
Problem Description
Weibo share webpage (WebPage) type, the link is only displayed as the text of "Webpage Link" on Weibo a
solution
Thumbnails are not displayed after sharing webpage type data. This belongs to Weibo’s mobile application business cooperation. LinkCard and attachment column integration sharing permissions in the mobile SDK need to apply to Weibo cooperation. For docking, please contact Weibo business: [email protected] .com.cn
Solution address: https://developer.umeng.com/docs/128606/detail/129488?spm=a311a.7996332.0.0.35323080nYHX02
36. Huawei honor 8.0 cannot open the app solution
1. If this attribute is set for the Activity in the Manifest
android:screenOrientation="portrait"
Delete this attribute and use it in the code instead
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
2. If this attribute is used in the theme, please delete it to solve the problem
<item name="android:windowIsTranslucent">true</item>
Original address: https://www.jianshu.com/p/f56e094b3ffb
37. Could not initialize class name.kropp.intellij.makefile.MakefileLanguage
Cause Android studio to freeze, just disable this plugin;
solution: https://segmentfault.com/a/1190000039350707
38. Execution failed for task ‘:app:kaptProdReleaseKotlin’.
Add the following configuration to the gradle.properties file;
kapt.use.worker.api=false
kapt.incremental.apt=false