Tag Archives: android error

[Solved] Resource compilation failed. Check logs for details.

Record the problems encountered that cannot be clearly answered by the search.

Error log:

Execution failed for task ‘:app:mergeDebugResources’.
> A failure occurred while executing com. android. build. gradle. internal. res.ResourceCompilerRunnable
> Resource compilation failed. Check logs for details.

* Try:
Run with –info or –debug option to get more log output. Run with –scan to get full insights.

Error: I added a string-array resource file, and “I’m here” used the abbreviation, which is what caused the above error.

Solution: no abbreviation, directly use “I am here”

 

Android Error: Failure [INSTALL_FAILED_USER_RESTRICTED: Invalid apk] in android

When debugging with Xiaomi mobile phone (MI Max 2), the application cannot be installed

Settings -> Additional settings -> Developer options ->

1. Close “MIUI optimization” and restart
2 Open “USB debugging”
3 Open “install via USB”
4 Set USB configuration to charging
5 Open “install via USB”**

next step

At this step, the problem of mismatch of SDK version has been fixed. Modify the SDK version

[Solved] Manifest merger failed with multiple errors, see logs

Adding a dependent library is an error when running, because the current project version is lower than the minimum trial version of the third-party dependent library

1. As shown in the current project’s build.gradle without setting the buildToolsVersion.

2. Set minSdkVersion to the minimum version of the dependency library in the current project’s build.gradle as shown here.

[Solved] Android Error: E/EGL_adreno: tid 3927: eglSurfaceAttrib(1334): error 0x3009 (EGL_BAD_MATCH)

1. Error Messages:

E/EGL_adreno: tid 3927: eglSurfaceAttrib(1334): error 0x3009 (EGL_BAD_MATCH)

java.lang.OutOfMemoryError: Failed to allocate a 146313228 byte allocation with 16777216 free bytes and 115MB until OOM

在这里插入图片描述

 

2. Reason

Description: The memory of our Android project is overflowing, my guess is that the reason may be the difference in resolution leading to memory overflow of the project content or too much content to load (images and other resources)
Especially controls that load a lot of data in a list have custom images.

 

3. Solution

Original Codes

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/Theme.MyFourth"
        >
        <activity
            android:name=".MainActivity"
            android:exported="true">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <service android:name=".service.MusicService"/>
    </application>

Add the following codes after <application:

android:largeHeap="true"
android:hardwareAccelerated="false"

Full Modified Codes

<application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/Theme.MyFourth"
        
        android:largeHeap="true"
        android:hardwareAccelerated="false"

        >
        <activity
            android:name=".MainActivity"
            android:exported="true">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <service android:name=".service.MusicService"/>
    </application>
android:hardwareAccelerated="true"

An application that uses largeHeap will request the system to allocate more memory space for the Dalvik virtual machine. It is also easy to use, just add android:largeHeap=”true” to the application node of the manifest file.

android:hardwareAccelerated="false" 

The default is true which will start hardware acceleration but will, however, take up memory

[Solved] Compile Error: AAPT: error: resource android:attr/lStar not found

Question

When using a third-party library, an error is reported during compilation

C:\Users\Administrator\.gradle\caches\transforms-2\files
2.1\b29f469d834fe6ac53c0c0e264e4ef98\core-1.7.0\res\values\values.xml
:105:5-114:25: AAPT: error: resource android:attr/lStar not found.

reason

Compatibility problems have caused the project to be compiled. However, the core-1.7.0 version is used in the third party library and core-1.6.0 is used in the project.

Solution:

Add the following code above dependencies{} in build.gradle

configurations.all {
    resolutionStrategy {
        force 'androidx.core:core:1.6.0'
    }
}

dependencies {
}

[Solved] Gradle NullPointerException at com.android.build.gradle.internal.ndk.NdkHandler.getPlatformVersion

Baidu does not have the answer to this question, to Google: reference https://github.com/luncliff/NdkCamera/issues/1 As mentioned in

the path to add NDK, you need to pay attention to a NDK version number. At the beginning, I directly referred to NDK, but I couldn’t do it without the following 21.0.6113669
so make a record in CSDN to facilitate future generations to find out, without going over the wall.

[Solved] ViewBinding Error: java.lang.ClassCastException: android.widget.RelativeLayout cannot be

prompt: after the article is written, the directory can be automatically generated. For how to generate it, please refer to the help document on the right </ font> for details

Java.lang.classcastexception encountered when using viewbinding: android.widget.relativelayout cannot be cast to cast to android.widget.textview

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content">
    <Button
        android:id="@+id/back"
        android:layout_margin="10dp"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_centerVertical="true"
        android:text="Back" />

    <TextView
        android:id="@+id/title"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerInParent="true"
        android:text="Title"
        android:textSize="20sp" />

    <Button
        android:id="@+id/done"
        android:layout_margin="10dp"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:layout_centerVertical="true"
        android:text="Done" />

</RelativeLayout>

In the XML of the title, the ID of textview is title

<include
        android:id="@+id/title"
        layout="@layout/titlebar" />
        

Use include < in the main interface>  When introducing a layout, the layout ID set is also the title,
when using viewbinding, there will be confusion, so the ID name should be set to different.

AAPT: error: ‘null‘ is incompatible with attribute button (attr) reference.

Problem description

When using radio button, I want to cancel the small circle he brought with me. Use the following code

 android:button="null"

It’s just an error caused by the @ sign in front of null. According to the error message, you can see error: “null”   I haven’t found any other bloggers for a long time. This family is all caused by font size or color. At the beginning, they thought that their error message was null, and no one made such a small mistake for an hour  

AAPT: error: 'null' is incompatible with attribute button (attr) reference.

Solution:

Note that the correct code is here·········

 android:button="@null"

 

[Android Error] java.lang.RuntimeException: An error occurred while executing doInBackground()

Recently, a bug was added to the task list to be resolved in this sprint. The stack information of the bug is as follows:

Fatal Exception: java.lang.RuntimeException: An error occurred while executing doInBackground()
       at android.os.AsyncTask$3.done(AsyncTask.java:353)
       at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:383)
       at java.util.concurrent.FutureTask.setException(FutureTask.java:252)
       at java.util.concurrent.FutureTask.run(FutureTask.java:271)
       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
       at java.lang.Thread.run(Thread.java:764)
Caused by java.lang.SecurityException: Caller no longer running, last stopped +25s437ms because: timed out while starting
       at android.os.Parcel.readException(Parcel.java:1942)
       at android.os.Parcel.readException(Parcel.java:1888)
       at android.app.job.IJobCallback$Stub$Proxy.dequeueWork(IJobCallback.java:191)
       at android.app.job.JobParameters.dequeueWork(JobParameters.java:196)
       at android.support.v4.app.JobIntentService$JobServiceEngineImpl.dequeueWork(JobIntentService.java:309)
       at android.support.v4.app.JobIntentService.dequeueWork(JobIntentService.java:627)
       at android.support.v4.app.JobIntentService$CommandProcessor.doInBackground(JobIntentService.java:384)
       at android.support.v4.app.JobIntentService$CommandProcessor.doInBackground(JobIntentService.java:377)
       at android.os.AsyncTask$2.call(AsyncTask.java:333)
       at java.util.concurrent.FutureTask.run(FutureTask.java:266)
       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
       at java.lang.Thread.run(Thread.java:764)

According to the above bug information, it can be known that the system JobIntentService, AsyncTask doInBackground is called, while doInBackground calls dequeueWork. The following is the source code (source code of androidx 1.1.0) :

final class CommandProcessor extends AsyncTask<Void, Void, Void> {
    @Override
    protected Void doInBackground(Void... params) {
        GenericWorkItem work;

        if (DEBUG) Log.d(TAG, "Starting to dequeue work...");

        while ((work = dequeueWork()) != null) {
            if (DEBUG) Log.d(TAG, "Processing next work: " + work);
            onHandleWork(work.getIntent());
            if (DEBUG) Log.d(TAG, "Completing work: " + work);
            work.complete();
        }

        if (DEBUG) Log.d(TAG, "Done processing work!");

        return null;
    }

dequeueWork() source code is as follows, let’s focus on mJobImpl! = null part, will enter mjobimpl.dequeuework () part:


    GenericWorkItem dequeueWork() {
        if (mJobImpl != null) {
            return mJobImpl.dequeueWork();
        } else {
            synchronized (mCompatQueue) {
                if (mCompatQueue.size() > 0) {
                    return mCompatQueue.remove(0);
                } else {
                    return null;
                }
            }
        }
    }

mJobImpl is actually a , CompatJobEngine, source code and is the implementation class JobServiceEngineImpl as follows:

	interface CompatJobEngine {
   		 IBinder compatGetBinder();
    	GenericWorkItem dequeueWork();
    }

	@RequiresApi(26)
	 static final class JobServiceEngineImpl extends JobServiceEngine
        implements JobIntentService.CompatJobEngine {
	 @Override
        public JobIntentService.GenericWorkItem dequeueWork() {
            JobWorkItem work;
            synchronized (mLock) {
                if (mParams == null) {
                    return null;
                }
                work = mParams.dequeueWork();
            }
            if (work != null) {
                work.getIntent().setExtrasClassLoader(mService.getClassLoader());
                return new WrapperWorkItem(work);
            } else {
                return null;
            }
        }
    }

As you can see from the bug information at the beginning of the article, it goes to mparams.dequeuework (); Binder, then enter the Binder mechanism, the source code is as follows, so we can conclude that there is a problem here, throwing an exception, but because this is part of the source code, it should not be our responsibility.

	public @Nullable JobWorkItem dequeueWork() {
    try {
        return getCallback().dequeueWork(getJobId());
    } catch (RemoteException e) {
        throw e.rethrowFromSystemServer();
    }
}
		/** @hide */
    @UnsupportedAppUsage
    public IJobCallback getCallback() {
        return IJobCallback.Stub.asInterface(callback);
    }

After query source, found that the problem appeared in the framework layer, and there are already online issue of the problem: https://github.com/evernote/android-job/issues/255

https://issuetracker.google.com/issues/63622293 online encounter this kind of problem a lot of a lot of people, but so far, I have checked the latest Google androidx library ("androidx.core:core-ktx:1.2.0-rc01") and still haven’t solved this problem. App . In this package, a new class SafeJobIntentService</code b> is inserted into the JobIntentService. The reason for this is that the dequeueWork() method is not public. We have to write in the same package to override its methods and fix bugs.

@RestrictTo({Scope.LIBRARY})
public abstract class SafeJobIntentService extends JobIntentService {
    public SafeJobIntentService() {
    }

    GenericWorkItem dequeueWork() {
        try {
            return super.dequeueWork();//1 Here we do a try/catch operation on this method
        } catch (SecurityException var2) {
            var2.printStackTrace();
            return null;
        }
    }

    public void onCreate() {
        super.onCreate();
        if (VERSION.SDK_INT >= 26) {
            this.mJobImpl = new SafeJobServiceEngineImpl(this);
        } else {
            this.mJobImpl = null;
        }
    }
}

@RequiresApi(26)
public class SafeJobServiceEngineImpl extends JobServiceEngine implements CompatJobEngine {
    static final String TAG = "JobServiceEngineImpl";
    static final boolean DEBUG = false;
    final JobIntentService mService;
    final Object mLock = new Object();
    JobParameters mParams;

    SafeJobServiceEngineImpl(JobIntentService service) {
        super(service);
        this.mService = service;
    }

    public IBinder compatGetBinder() {
        return this.getBinder();
    }

    public boolean onStartJob(JobParameters params) {
        this.mParams = params;
        this.mService.ensureProcessorRunningLocked(false);
        return true;
    }

    public boolean onStopJob(JobParameters params) {
        boolean result = this.mService.doStopCurrentWork();
        synchronized(this.mLock) {
            this.mParams = null;
            return result;
        }
    }

    public GenericWorkItem dequeueWork() {
        JobWorkItem work = null;
        synchronized(this.mLock) {
            if (this.mParams == null) {
                return null;
            }

            try {
                work = this.mParams.dequeueWork();
            } catch (SecurityException var5) {
                var5.printStackTrace();
            }
        }

        if (work != null) {
            work.getIntent().setExtrasClassLoader(this.mService.getClassLoader());
            return new SafeJobServiceEngineImpl.WrapperWorkItem(work);
        } else {
            return null;
        }
    }

    final class WrapperWorkItem implements GenericWorkItem {
        final JobWorkItem mJobWork;

        WrapperWorkItem(JobWorkItem jobWork) {
            this.mJobWork = jobWork;
        }

        public Intent getIntent() {
            return this.mJobWork.getIntent();
        }

        public void complete() {
            synchronized(SafeJobServiceEngineImpl.this.mLock) {
                if (SafeJobServiceEngineImpl.this.mParams != null) {
                    try {
                        SafeJobServiceEngineImpl.this.mParams.completeWork(this.mJobWork);
                    } catch (SecurityException  | IllegalArgumentException var4) {
                    // 2 Here we also perform a try/catch operation on the completeWork
                        var4.printStackTrace();
                    }
                }
            }
        }
    }
}

On the basis of the source code, the above code only handles Exception at 1 and 2</code b>. The rest of the code does not change, so we can compare the source code to see the comparison. If you have a three-party library in your project that has introduced this SafeJobIntentService class, but because you can't use this class of them, and you refer to such as implementation 'com.evernote:android-job:1.4.2' library, duplicate class found in the module. If this problem occurs, we can rename the class and follow the above code to deal with it. Hopefully Google will add a solution to this problem in future libraries.
JSON has three methods for parsing data

Android Error: Consumer closed input channel or an error occurred. events=0x9

Android. OS. DeadObjectException memory near r0: exception handling

android.os.DeadObjectException
08-15 14:39:32. 486: W/System. Err (1767) : an android. The OS. BinderProxy. Transact (Native Method)
486: I/ActivityManager(1767): Process com.my.Test (PID 25619) has died.
08-15 14:39:32.486: W/ActivityManager(1767): Force Removal ActivityRecord{42afefe8 com.my.tes/.MyCmge}: app died, no saved state
08-15 14:39:32. 486: W/WindowManager (1767) : the Force – o child Windows Window {441 d3f70 PopupWindow: 4299 edc8 paused = false} the from the container Window {42 ae1b88 com. My. Tes/com. My. Tes. MyCmge paused = false}
08-15 14:39:32. 491: W/System. Err (1767) : an android. The IWindow $$Proxy stubs. OffsetWindowForKeyguard (IWindow. Java: 471)
08-15 14:39:32. 491: W/InputDispatcher (1767) : channel ‘441 da238 com. My. Tes/com. My. Tes. MyCmge (server)’ ~ Consumer closed input channel or an error occurred. The events = 0 x9
08-15 14:39:32. 491: E/InputDispatcher (1767) : channel ‘441 da238 com. My. Tes/com. My. Tes. MyCmge (server)’ ~ channel is unrecoverably broken and will be disposed.
08-15 14:39:32. 491: W/System. Err (1767) : at the android. Server. Wm. WindowStateAnimator. DestroySurfaceLocked (WindowStateAnimator. Java: 803)
08-15 14:39:32. 491: W/System. Err (1767) : at the android. Server. Wm. WindowState. RemoveLocked (WindowState. Java: 832)
08-15 14:39:32. 491: W/System. Err (1767) : at the android. Server. Wm. WindowManagerService. RemoveWindowInnerLocked (WindowManagerService. Java: 2522)
08-15 14:39:32. 491: W/System. Err (1767) : at the android. Server. Wm. WindowManagerService. RemoveWindowInnerLocked (WindowManagerService. Java: 2506)
491: D/Zygote(1550): Process 25619 by signal (11)
08-15 14:39:32. 491: W/System. Err (1767) : at the android. Server. Wm. WindowManagerService. RemoveWindowLocked (WindowManagerService. Java: 2484)
08-15 14:39:32. 491: W/System. Err (1767) : at the android. Server wm. WindowState $DeathRecipient. BinderDied (WindowState. Java: 869)
08-15 14:39:32. 491: W/System. Err (1767) : an android. The OS. BinderProxy. SendDeathNotice (449) Binder. Java:
08-15 14:39:32. 491: W/System. Err (1767) : at dalvik. System. NativeStart. Run (Native Method)
491: I/AKMD2(1767): AK8975/B for Android end
08-15 14:39:32 491: D/AKMD2(1767): AKMD2: Compass Closed.
08-15 14:39:32.491: D/Sensors(1767): AKM :setDelay():handle 1, delay 20000000 ns.
08-15 14:39:32.496: D/AKMD2(1767): ACC_thread_main: update delay_MS to 66.

Since I was using someone else’s SDK, I could not change the source code, so I asked Daniel for help and used the following method to solve it easily

application
Android: hardwareAccelerated = “false”…
In the application tag to add a android: hardwareAccelerated = “false” (disable hardware acceleration)
So the problem was solved,
At the beginning, I added it to the corresponding activity tag. As a result, I found that it could run perfectly for the first time and this problem would occur again after a period of time.
To change the application, the android: hardwareAccelerated = “false” so good,