December 23, 2019 15:57:41
Jane turned to gold, Jane too many ads, can’t stand the original chain
May 5, 2017 19:27:55
A null pointer error was reported after dependency injection after ButterKnife8.0
Solution: Because the runtime code plug-in is updated after 8.0, it needs to be configured
classpath 'com. Neenbedankt. Gradle. Plugins: android - apt: 1.8'
Copy the code
The easiest way to do this, however, is to rely on Butterknife instead
annotationProcessor 'com. Jakewharton: butterknife - compiler: 8.4.0'
Copy the code
May 5, 2017 20:00:11
You must not call setTag() on a view Glide is targeting
Solution: This error is often caused by the use of ListView or RecyclerView, its Item layout is abbreviated, the solution only needs to increase the Item parent layout
November 10, 2017 10:08:18
Glide loading large drawing has stretched problem. First set your ImageView’s scaleType property to centerCrop, then use Glide to do the following
Glide.with(context).load(url).asBitmap().centerCrop().placeholder(R.drawable.defaultpic).into(imageview);
Copy the code
January 9, 2018 16:06:56
Glide V4 dependency error
A message is displayed indicating that the Support resource cannot be found. You only need to upgrade the Support version, preferably at least 26
implementation 'com.android.support:appcompat-v7:27+'
implementation 'com.android.support:design:27.+'
Copy the code
July 19, 2018, 14:32:37
Configuration ‘compile’ is obsolete and has been replaced with ‘implementation’. It will be removed at the end of 2018
Prompt to replace compile with implementation, and compile will be deleted by the end of 2018
July 19, 2018 14:38:08
The SourceSet ‘instrumentTest’ is not recognized by the Android Gradle Plugin.
InstrumentTest instrumentTest is obsolete after update. Use androidTest instead
July 19, 2018, 14:48:39
DSL element ‘DexOptions.incremental’ is obsolete and will be removed at the end of 2018
Incremental = true can be deleted.
August 9, 2018 13:52:22
There is always a blank space inside the Toolbar to the left that cannot be filled in
Add the following code to the Toolbar layout
app:contentInsetLeft="0dp"
app:contentInsetStart="0dp"
Copy the code
10:34:24 on August 18, 2018
Custom dialogs always have a white edge at the top, and linear layout nested TextViews at the bottom always have no rounded corners
AdjustViewBounds =" True "(adjustViewBounds= trueCopy the code
August 18, 2018 11:20:27
OPPO’s mobile phone clicked “OK” after the photo was taken, but there was no response. After checking, it was found that the problem was caused by the path of saving the picture. It worked normally after changing the path to the following
Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DCIM).getAbsolutePath()
Copy the code
August 23, 2018 11:53:43
Android nested H5, H5 cannot display the content through javascript call, change the UL of H5 to div wrap UL to restore normal
October 11, 2018 16:20:29
EventBus reported an error after the mix-up. It is normal to add the following code to the mix-up file
-keepattributes *Annotation*
-keepclassmembers class ** {
@org.greenrobot.eventbus.Subscribe <methods>;
}
-keep enum org.greenrobot.eventbus.ThreadMode { *; }
# Only required if you use AsyncExecutor
-keepclassmembers class * extends org.greenrobot.eventbus.util.ThrowableFailureEvent {
<init>(java.lang.Throwable);
}
Copy the code
October 19, 2018 09:14:51
An error is reported when trying to use Dagger2
Could not find method apt() forArguments [com.google.dagger:dagger- Compiler :2.6] on object oftype org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.
Copy the code
Will rely on apt in… AnnotationProcessor instead…
References: With Android Gradle Plugin 2.2.0 release the android-apt plugin is no longer needed for annotation processing. The apt function was included in the latest android gradle plugin which called annotationProcessor.
compile 'com. Google. Dagger: a dagger: 2.6'
annotationProcessor Com. Google. "dagger: a dagger - compiler: 2.6"
Copy the code
October 31, 2018 11:15:38
Android ContextThemeWrapper cannot be cast to android.app.Activity
Add the following code:
private static Activity checkActivity(Context context) {
if (context == null) {return null;
} else if (context instanceof Activity){
return (Activity)context ;
} else if (context instanceof ContextWrapper){
return checkActivity(((ContextWrapper)context).getBaseContext());
}
return null;
}
Copy the code
A call:
TextView tvView = new TextView(checkActivity(getContext()));
Copy the code
November 6, 2018 09:14:13
Remove Tencent X5 browser slider (native slider removal method does not work on X5)
if(infoWebView.getX5WebViewExtension() ! = null) { infoWebView.getX5WebViewExtension().setHorizontalScrollBarEnabled(false); . / / level does not display the scroll button infoWebView getX5WebViewExtension () setVerticalScrollBarEnabled (false); // Vertical scroll button is not displayed}Copy the code
November 17, 2018, 14:04:17
Determines whether the currently active Activity contains the specified Activity
/** * Check whether MainActivity is active **@paramActivityName To identify activities, it is best to pass the package name *@return boolean
*/
private boolean isMainActivityAlive(Context context, String activityName) {
ActivityManager am = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
List<ActivityManager.RunningTaskInfo> list = am.getRunningTasks(100);
for (ActivityManager.RunningTaskInfo info : list) {
// Note that topActivity contains packageName and className
if (info.topActivity.toString().contains(activityName) || info.baseActivity.toString().contains(activityName)) {
LogUtils.e(TAG, info.topActivity.getPackageName() + " info.baseActivity.getPackageName()=" + info.baseActivity.getPackageName());
return true; }}return false;
}
Copy the code
November 23, 2018 14:30:35
AS project compilation error
Configuration on demand is not supported by the current version of the Android Gradle plugin since you are using Gradle version 4.6 or above. Suggestion: disable configuration on demand by setting org.gradle.configureondemand=false inGradle. Properties file or use a Gradle version less than 4.6.Copy the code
In the gradle-wrapper.properties file, change the distributionUrl parameter below 4.6
Create a file res -> XML ->network_security_config. XML and fill in the following:
<?xml version="1.0" encoding="utf-8"? >
<network-security-config>
<base-config cleartextTrafficPermitted="true">
<trust-anchors>
<certificates src="system" />
</trust-anchors>
</base-config>
</network-security-config>
Copy the code
In the AndroidManifest ->application node add:
android:networkSecurityConfig="@xml/network_security_config"
Copy the code
December 18, 2018 11:33:57
Android P update to P using HTTPClient
java.lang.RuntimeException: Stub!     at org.apache.http.message.BasicNameValuePair.<init>(BasicNameValuePair.java:6)
Copy the code
After Android P, the org.apache.http.legacy library will be removed from bootclasspath and therefore cannot be used. Official documents:
Deprecation of the Apache HTTP client affects applications that use non-standard ClassLoaders
Whisper BB(also can do, forced to accept……) Add to AndroidManifest -> Application:
<uses-library
android:name="org.apache.http.legacy"
android:required="false"/>
Copy the code
January 10, 2019 11:11:58
Manifest merger failed with multiple errors, see logsCopy the code
Solution: Switch to Terminal and run the following command to view detailed errors
gradlew processDebugManifest --stacktrace
Copy the code
February 25, 2019 09:13:49
ERROR: Failed to resolve: support-media-compat
Copy the code
Cause: baffling error, baffling wall, baffling dregs Solution:
mavenCentral()
google()
jcenter()
Copy the code
Change for
maven { url 'https://maven.aliyun.com/repository/google' }
maven { url 'https://maven.aliyun.com/repository/jcenter' }
maven { url 'http://maven.aliyun.com/nexus/content/groups/public' }
Copy the code
The final should be as follows:
buildscript {
repositories {
// jcenter()
// mavenCentral()
// google()
maven { url 'https://maven.aliyun.com/repository/google' }
maven { url 'https://maven.aliyun.com/repository/jcenter' }
maven { url 'http://maven.aliyun.com/nexus/content/groups/public' }
}
dependencies {
...
}
}
allprojects {
repositories {
// mavenCentral()
// jcenter()
// google()
maven { url 'https://maven.aliyun.com/repository/google' }
maven { url 'https://maven.aliyun.com/repository/jcenter' }
maven { url 'http://maven.aliyun.com/nexus/content/groups/public'}... }}Copy the code
April 15, 2019 15:26:46
The EditText clearFocus() method is invalid A look at the source code shows that clearFocus does not actually clearFocus, but instead walks through the layout to get a View with focusInTouchMode true. If EditText is first, the focus is reset again, which is in an infinite loop, so it looks invalid The view before itText sets the following properties
android:focusableInTouchMode="true"
Copy the code
July 26, 2019 15:26:45
AndroidManifast Warning GoogleAppIndexingWarning App is not Indexable by Google Search
<action android:name="android.intent.action.VIEW" />
Copy the code
Or press Alt+Enter to ignore it
October 22, 2019 14:55:29
An error occurred when the page was reloaded after switching programs from the background
java.lang.IllegalArgumentException: Wrong state class.expecting View State but received class android.support.v7.widget.Toolbar$SavedState instead. This usually happens when two views of different type have the same id in the same hierarchy. This view's id is id/toolbar. Make sure other views do not use the same id
Copy the code
Error: The toolbar ID is repeated when the page reloads, and the toolbar ID is the same as the toolbar ID. After accidentally discovering that the layout includes the toolbar ID and the toolb. XML toolbar ID are both toolb’s internal toolb After the AR ID is changed, the problem is rectified.
<include
android:id="@+id/toolbar"
layout="@layout/toolbar"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
binding:toolbarViewModel="@{mainViewModel.toolbarViewModel}" />
Copy the code
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="0dp"
android:layout_height="49dp"
android:minHeight="? attr/actionBarSize"
android:theme="? attr/actionBarTheme"
app:contentInsetLeft="0dp"
app:contentInsetStart="0dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
Copy the code
The above ID is repeated, causing the problem
December 31, 2019 09:52:51
Old project upgrade error reported
NoClassDefFoundError: Failed resolution of: Lorg/apache/http/params/BasicHttpParams
Copy the code
To the manifest file application tag
<application
.>
<uses-library android:name="org.apache.http.legacy" android:required="false" />
</application>
Copy the code
Add build file under Android
android {
...
useLibrary 'org.apache.http.legacy'
}
Copy the code