1. Dynamically change the color value of the Shape’s solid property

We often use Shape in XML, and we may want to use the same Shape in development, but the color background is different.

/ / such as:  <shape xmlns:android="http://schemas.android.com/apk/res/android"> <corners android:radius="5dp" /> <solid android:color="@color/white" /> </shape>Copy the code

Solutions:

// We can change the background color dynamically in the Activity, so we don't need to rewrite the shape. GradientDrawable =(GradientDrawable)view.getBackground(); drawable.setColor(getResources().getColor(color));Copy the code

2. Android Studio creates new projects and keeps building solutions

The main reason, perhaps, is that your Version of Android Studio doesn’t match it, or it’s being blocked. I could not download gradle, so I kept building

C: Users\Administrator. Gradle \wrapper\dists This is my address, you find yours

The solution is to find your new project

Modify the 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
Copy the code

Keep in mind that your gradle-2.10-all file is not empty, otherwise you still need to wait for the building. Another way is to go to (services.gradle.org/distributio… Gradle, placed in C:\Users\Administrator. Gradle \wrapper\dists folder. You may also report the following error after you have modified it,

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)
Copy the code

So let’s just shut down Android Studio and findlogThe logs. Delete all


3.JNI compilation error encoding GBK unmapped character solution

The reason for this error is that since the JDK is international, if we do not specify the encoding of our JAVA source at compile time with the -encoding argument, javac.exe first gets the encoding that our operating system defaults to.

The -encoding argument should be used to specify the encoding, as in:

javah -jni -encoding UTF-8 com.example.XXXX.XXXX.MainActivity
Copy the code

4. Jar conflict of umeng wechat Payment

If you use the simplified version of wechat, there is no content related to payment. If you want to add payment, just delete the JAR of UmengWX (keep Weixin2) and put it into the wechat native JAR. If you are using the full version of wechat, weixin1 jar is the same jar with the wechat native SDK (only the name is different), so please use weixin1 jar to ensure the same version, and delete the wechat native SDK to realize payment.

Cause: Libammsdk. jar, socialsdk_weixin_1. jar, both packages contain the same A.class file.

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
Copy the code

The above paragraph shows UmENG’s solution, which looks a bit stiff

Note: I used the full version. Jar packages libammsdK. jar and socialsdk_weixin_2. jar are used, and the original socialsdk_weixin_1. jar and socialsdk_weixin_2. jar packages are deleted, resulting in failure to call wechat payment.

In the final solution, use socialsdk_weixin_1. jar and socialsdk_weixin_full. jar to avoid conflicts. All other old packs are dead.

5. The HTTPS page loaded by the [Android] WebView cannot display resources properly

Skip to the address: blog.csdn.net/crazy_zihao…

6. ImageView (fitXY) properties

The effect of fitXY is to stretch the image to fill space according to the size set by the ImageView, which distorts the image. AdjustViewBounds is to restrict pictures to keep their original size when they are displayed. (Combined with fitXY display mode to 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)
Copy the code

Solution: www.apkbus.com/blog-898535…

8. About the use of RecycleView, Item layout is high, display incomplete layout problem.

Android :layout_height=”match_parent” uses this property, resulting in only one screen being drawn. We put the outermost property of the layout ** Android :layout_height=”wrap_content”** to avoid incomplete drawing.

9. Configure the application ID and application key

  1. 9, Access the website ai.Netease, Then register and access your account.
  2. Go to App Management — My app — create an app
  3. It’s time to see the magic. Two pictures

Then it’s time to get to work. I don’t have to tell you.

#Error:(176, 13) Failed to resolve: #Error:(176, 13) Failed to resolve: ** 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/'
        }
    }
Copy the code

10. In Java. Lang. NoClassDefFoundError: under the Android 5.0

The reason is that the number of project methods exceeded the dex limit of 65535. MultiDexEnabled True is enabled, but multidex.install (base) is not initialized in the Application. Add the method to the Application class.

  @Override
    protected void attachBaseContext(Context base) {
        super.attachBaseContext(base);
        MultiDex.install(base);
    }
Copy the code

Solution: www.jianshu.com/p/8b4f711da…

11. In Java. Lang. NoClassDefFoundError: Failed resolution of: Lcom/ta/utdid2 / device/UTDevice

If you are using the Umalliance SDK, check to see if there are no packages introduced

The compile 'com. Umeng. SDK: utdid: 1.1.5.3'Copy the code

Written after Android Studio 3.0

Implementation 'com. Umeng. SDK: utdid: 1.1.5.3'Copy the code

If you still get an error, there may be a conflict with Ali’s bag. The solution Please jump: help.aliyun.com/knowledge_d…

12. Umeng Device_token can not be obtained

Solution: Go to bbs.umeng.com/thread-1523…

13.cannot find implementation for WordRoomDatabase. WordRoomDatabase_Impl does not exist

The problem:

  1. Check whether the project uses Kotlin. If so, 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 28 versionCode targetSdkVersion 1 versionName testInstrumentationRunner "1.0" "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. The constraint, the 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' / / is mainly the three, You have to see if it's consistent, if it's used correctly, If you use the kotlin three necessary implementation "android. Arch. Persistence. Room: the runtime: 1.1.1" / / look for the suffix is not the same room: the compiler AnnotationProcessor "android. Arch. Persistence. Room: the compiler: 1.1.1" kapt "android. Arch. Persistence. Room: the compiler: 1.1.1" Implementation 'android. Arch. Lifecycle: extensions: 1.1.1' implementation "Android. Arch. Navigation: navigation - fragments: 1.0.0 - alpha07" implementation "Android. Arch. Navigation: navigation - UI: 1.0.0 - alpha07"}Copy the code

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: Github.com/ReactiveX/R… | kotlin.NotImplementedError: An operation is not implemented: not implemented

The solution: blog.csdn.net/lmh820822/a…

15. java.lang.RuntimeException: Unable to start activity ComponentInfo{xxxActivity}: java.lang.IllegalStateException: Only fullscreen opaque activities can request orientation

Cause analysis targetsdk26 above, for transparent theme activity can’t through the manifest set android: screenOrientation. Concrete analysis see here zhuanlan.zhihu.com/p/32190223 solution check whether the Activity of an error in the AndroidManifest declares the android: screenOrientation, if there is need to be removed.

16. The abnormal OKHttp Java. Lang. An IllegalStateException: closed and the debug of the pit

Solution to address: blog.csdn.net/u012587005/…

17.Android multi-language switching, adapted to 8.0

Solve the address: www.jianshu.com/p/f56e30b6f… For specific reasons, if the system is above 8.0, you need to use the Activity context.

18.android Typeerror:Cannot read property ‘xxxx’ null

Address: www.e-learn.cn/content/wan…

19.Expected Android API level 21+ but was 19

Check to see if your Okhttp version implementation ‘com. Squareup. Okhttp3: logging – interceptor: 3.14.0’ into implementation ‘com. Squareup. Okhttp3: logging – interceptor: 3.12.0’ need to downgrade version

Android Studio Terminal Git log garble problem solution

Terminal: Set LESSCHARSET= UTF-8

21. java.lang.IllegalArgumentException: Parameter specified as non-null is null: method kotlin.jvm.internal.Intrinsics.checkParameterIsNotNull, parameter favicon

Solution: blog.csdn.net/jia635/arti…

22. Application of signature claim

Jarsigner -verbose -keystore [key file path]C:\sign_verification\mykeystore -signedjar [packaged package name and path]meizu.apk [unsigned package name]meizuemptyapk- releaseunsigned. Apk [alias of key]meizu

23. AndroidStudio does not show 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 page does not refresh

Solution: https://blog.csdn.net/qq_26225663/article/details/100557671

26. Google App Marketplace replacement key scheme

Support.google.com/googleplay/…Communicate with customer service and wait for the official reply from Google. The followingExport the certificate for this key to PEM format: Run keytool -export -rfc -alias upload -file upload_certificate.pem -keystore keystore. JKS to generate a PEM file. Just send it to Google’s official email address

Android Missing permission to insert badges badges on a user

The situation is also strange, only SONY models appear this permission error, various searches, finally found that the need to add some special models in the androidmanifest.xml permissions. Without further ado, here it is:

<! -- 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 -->Copy the code

28. Android-Device supports x86,but APK only supports armeabi-v7a,armeabi,x86_64

Solution: blog.csdn.net/qq_34476727…

29. java.io.FileNotFoundException: /storage/emulated/0/

Specific reason for this is that because the current project using the Android is the Q version, corresponding to the version number is 29 have this BUG solution: www.jianshu.com/p/3159f2c5b…

30. android 10 Permission denied

Solution: blog.csdn.net/wuqingsen1/…

31. Wireless debugging of Android Studio for real machines

Using the tutorial: www.cnblogs.com/chenlove/p/…

32.Android11 application side adaptation

Juejin. Cn/post / 689081…

33.Android studio updating symbols

Stackoverflow.com/questions/3…

-Xms256m
-Xmx8192m
-XX:ReservedCodeCacheSize=2048m
-XX:+UseCompressedOops
-XX:MaxPermSize=4096m
Copy the code

Click “help” — “Edit Custom VM Options “to add the above code mainly because the Android Studio runtime memory allocation is insufficient and loading is too slow

Copy the code