Tag Archives: Mobile development

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] AndroidStudio Error: checkDebugAarMetadata & CheckAarMetadataWorkAction

Description

Execution failed for task ':app:checkDebugAarMetadata'.

> Multiple task action failures occurred:

   > A failure occurred while executing com.android.build.gradle.internal.tasks.CheckAarMetadataWorkAction

      > The minCompileSdk (31) specified in a

        dependency's AAR metadata (META-INF/com/android/build/gradle/aar-metadata.properties)

        is greater than this module's compileSdkVersion (android-30).

        Dependency: androidx.recyclerview:recyclerview:1.3.0-alpha02.

If you upgrade to compilesdk 31 according to the prompt, you are faced with a large number of Android 12 and below are not available, and upgrade the current jdk8 to jdk11 or above, but the set of source code was still available more than 2 months ago. Now it is not available for no reason, which is not in line with the routine.

If the current compilesdk is kept at 30 or 28, gradle compiles and passes, but the above error is reported when running debugging.

I can’t understand it.

Solution:

Take the following three steps to finally solve the problem
1. keep the current compilesdk at 30 or 28.

2. lower the corresponding version number of dependent components, such as dependency: Android. Recyclerview: recyclerview: 1.3.0-alpha02. Change the original version number of the corresponding gradle file from 1. + to 1.2. +, that is, lower the version number by one. Shape such as

The original gradle file is implementation 'androidx.recyclerview:recyclerview:1.+'// means 1.xx latest version, maybe 1.0, 1.1, 1.2, 1.3, 1.4, 1.5 in that order

Now read
implementation 'androidx.recyclerview:recyclerview:1.2.+'// means 1.2.xx latest version, maybe 1.2.0, 1.2.1, 1.2.2, 1.2.3, 1.2.4, 1.2.5 in that order

3. After recompiling, debug and run again, and the prompt of the dependent component does not appear again, indicating that the modification is effective. By analogy, reduce the version number of other dependent components until similar prompt no longer appears, and the problem is solved.

Android Error: Android resource linking failed [How to Solve]

Problems encountered during compilation during development:

Android resource linking failed

Output:  error: resource style/Theme.AppCompat.Light.DarkActionBar (aka com.hp.sortfilebysize:style/Theme.AppCompat.Light.DarkActionBar) not found.

E:\ASWorkSpace\SortFileBySize\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml:9: error: style attribute 'attr/colorPrimary (aka com.hp.sortfilebysize:attr/colorPrimary)' not found.

E:\ASWorkSpace\SortFileBySize\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml:10: error: style attribute 'attr/colorPrimaryDark (aka com.hp.sortfilebysize:attr/colorPrimaryDark)' not found.

E:\ASWorkSpace\SortFileBySize\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml:11: error: style attribute 'attr/colorAccent (aka com.hp.sortfilebysize:attr/colorAccent)' not found.

error: failed linking references.

Command: C:\Users\tangdekun\.gradle\caches\transforms-1\files-1.1\aapt2-3.2.0-beta03-4818971-windows.jar\868db5e9c484c628dee78cdbe6877651\aapt2-3.2.0-beta03-4818971-windows\aapt2.exe link -I\

        N:\ProgramFiles\android\sdk\platforms\android-28\android.jar\

        --manifest\

        E:\ASWorkSpace\SortFileBySize\app\build\intermediates\merged_manifests\debug\processDebugManifest\merged\AndroidManifest.xml\

        -o\

        E:\ASWorkSpace\SortFileBySize\app\build\intermediates\processed_res\debug\processDebugResources\out\resources-debug.ap_\

        -R\

        @E:\ASWorkSpace\SortFileBySize\app\build\intermediates\incremental\processDebugResources\resources-list-for-resources-debug.ap_.txt\

        --auto-add-overlay\

        --java\

        E:\ASWorkSpace\SortFileBySize\app\build\generated\not_namespaced_r_class_sources\debug\processDebugResources\r\

        --custom-package\

        com.hp.sortfilebysize\

        -0\

        apk\

        --output-text-symbols\

        E:\ASWorkSpace\SortFileBySize\app\build\intermediates\symbols\debug\R.txt\

        --no-version-vectors

For errors like this, you have tried to add “implementation ‘Android x.appcompat: appcompat: 1.0.0-alpha1’, but it still fails. You can try the following method to solve it

Enter caches under. Gradle

Delete transform-1 and restart Android studio (file → invalidate caches/restart → invalidate caches and restart)

error: could not install *smartsocket* listener: Address already in use PM8:49 ADB server didn’t AC…

Enter adb command in the terminal and the error is as follows:
localhost:work zhangyg$ adb devices
List of devices attached
adb server version (32) doesn’t match this client (36); killing…
error: could not install *smartsocket* listener: Address already in use
ADB server didn’t ACK
* failed to start daemon *
error: cannot connect to daemon

The reason for the error was that I chose Android Tools using Genymotion, so it caused a conflict with ADB program under Android SDK.
Click [Settings] in the main interface of Genymotion as shown below:

Select Use Custom Android SDK Tools, and then select the Androd SDK root directory, as shown in the figure below:

Restarting Genymotion’s virtual machine will solve the problem.

Flutter FAQ-Error retrieving device properties for ro.product.cpu.abi

The solution
In order to avoid any detours seen later, the solution is posted directly. The rest of the content is just to record and restore the problem.
How to: Replace Android Platform Tools 29 with Android Platform Tools 28. Download the link at the end of the article.
Problem reproduction
Oddly enough, I went out for an experimental class, and when I came back Android Studio couldn’t compile the Flutter app. The output of the console part is as follows:

Exit code -1073740940 from C:\SDK\platform-tools\adb -s emulator-5554 shell -x logcat -v time -t l

Bash adb --version output:

Android Debug Bridge version 1.0.40
Version 29.0.1-5303910
Installed as C:\SDK\platform-tools\adb.exe

Since taicai did not see any problem, he thought to go to doctor to check the problem with flutter. The partial output is as follows:

[√] Flutter (Channel master, v1.7.2-pre.30, on Microsoft Windows [Version 10.0.17763.529], locale zh-CN)
[!]  Android toolchain - develop for Android devices (Android SDK version 29.0.1)
     × Android license status unknown.
     Try re-installing or updating your Android SDK Manager.
     See https://developer.android.com/studio/#downloads or visit https://flutterchina.club/using-ide/ to get more instructions.
[√] Android Studio (version 3.4)
[√] VS Code, 64-bit edition (version 1.34.0)
[!] Connected device
    ! No devices available
!   Doctor found issuses in 2 categories.

So the problem is probably the Android License, right?Fortunately, the solution is as follows: reinstall or upgrade SDK Manager
First, enter the bin directory of SDK tools, CD C:\SDK\tools\bin, and directly execute sdkmanager --update. I thought everything would be ok, but the output is as follows:

Exception in thread "main" java.lang.NoClassDefFoundError: javax/xml/bind/annotation/XmlSchema

Apparently the solution given by Doctor Flutter didn’t work, so I had to scan the Internet for a flutter. Solutions such as adb kill don’t work
In my anger, I reinstalled Android Studio. After docor, I got an extra line of output as follows:

Error retrieving device properties for ro.product.cpu.abi

However, there was still no solution for goose to search with this method, so she had to go out and look for over the wall (after all, Google stuff) and soon found the first issue of 26 May 2017. The dropdown is basically an unresolved problem. So I continued to find the issue of the second 23 Apr 2018. At the end of the page, I found the following comment, which was published two days ago, namely June June 2019, which was about the same time as my problem

This is a problem with platform tools 29. Temporary fix in my issue

According to the comment, it should be the problem of Platform Tools 29. He mentioned an issue later and got a solution after clicking on it.

Install the latest version of android studio beta on windows (platform tools 29 will be installed)

OK, so that’s the easy part, degrade Platform Tools

    open the folder where the SDK is located and remove the platform-tools folder (make sure the adb related process is finished) unzip the platform-tools 28 and put it in and replace it with

(The SDK Manager for Android Studio also seems to be able to degrade directly, but I don’t know why this doesn’t work, so I recommend downloading a manual replacement.)
Here is the download address:

Windows: http://dl-ssl.google.com/android/repository/platform-tools_r28.0.2-windows.zip
macOS: http://dl-ssl.google.com/android/repository/platform-tools_r28.0.2-darwin.zip
Linux: http://dl-ssl.google.com/android/repository/platform-tools_r28.0.2-linux.zip

OK, bash once doctor, all green through ~
Open AVD group photo, end scattering flowers ~

I found a temporary fix while we wait for a solution provided by the Flutter team
Hopefully flutter will be good for me ~ less of this bug~

java.lang.IllegalStateException: Could not execute method for android:onClick

I didn’t think about it before I heard it..

Error screenshot

error message

E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.example.imoocmusicdemo, PID: 14631
    java.lang.IllegalStateException: Could not execute method for android:onClick
        at android.view.View$DeclaredOnClickListener.onClick(View.java:5634)
        at android.view.View.performClick(View.java:6597)
        at android.view.View.performClickInternal(View.java:6574)
        at android.view.View.access$3100(View.java:778)
        at android.view.View$PerformClick.run(View.java:25885)
        at android.os.Handler.handleCallback(Handler.java:873)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loop(Looper.java:193)
        at android.app.ActivityThread.main(ActivityThread.java:6669)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
     Caused by: java.lang.reflect.InvocationTargetException
        at java.lang.reflect.Method.invoke(Native Method)
        at android.view.View$DeclaredOnClickListener.onClick(View.java:5629)
        at android.view.View.performClick(View.java:6597) 
        at android.view.View.performClickInternal(View.java:6574) 
        at android.view.View.access$3100(View.java:778) 
        at android.view.View$PerformClick.run(View.java:25885) 
        at android.os.Handler.handleCallback(Handler.java:873) 
        at android.os.Handler.dispatchMessage(Handler.java:99) 
        at android.os.Looper.loop(Looper.java:193) 
        at android.app.ActivityThread.main(ActivityThread.java:6669) 
        at java.lang.reflect.Method.invoke(Native Method) 
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858) 
     Caused by: android.content.ActivityNotFoundException: Unable to find explicit activity class {com.example.imoocmusicdemo/com.example.imoocmusicdemo.activitys.RegisterActivity}; have you declared this activity in your AndroidManifest.xml?
        at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:2005)
        at android.app.Instrumentation.execStartActivity(Instrumentation.java:1673)
        at android.app.Activity.startActivityForResult(Activity.java:4586)
        at android.app.Activity.startActivityForResult(Activity.java:4544)
        at android.app.Activity.startActivity(Activity.java:4905)
        at android.app.Activity.startActivity(Activity.java:4873)
        at com.example.imoocmusicdemo.activitys.LoginActivity.onRegisterClick(LoginActivity.java:40)
        at java.lang.reflect.Method.invoke(Native Method) 
        at android.view.View$DeclaredOnClickListener.onClick(View.java:5629) 
        at android.view.View.performClick(View.java:6597) 
        at android.view.View.performClickInternal(View.java:6574) 
        at android.view.View.access$3100(View.java:778) 
        at android.view.View$PerformClick.run(View.java:25885) 
        at android.os.Handler.handleCallback(Handler.java:873) 
        at android.os.Handler.dispatchMessage(Handler.java:99) 
        at android.os.Looper.loop(Looper.java:193) 
        at android.app.ActivityThread.main(ActivityThread.java:6669) 
        at java.lang.reflect.Method.invoke(Native Method) 
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858) 
I/Process: Sending signal. PID: 14631 SIG: 9
Application terminated.

Cause of error

Caused by: android.content.ActivityNotFoundException: Unable to find explicit activity class {com.example.imoocmusicdemo/com.example.imoocmusicdemo.activitys.RegisterActivity}; have you declared this activity in your AndroidManifest.xml?

resolvent: AndroidManifest.xml Add registeractivity

The reason and solution of Android intent value not updated

When the Activity’s launch mode is singleTask or singleInstance. If an intent is used to pass a value, then the problem may arise that the intent’s value cannot be updated. That is, the value received for each Intent is the value received for the first time. Because the intent has not been updated. To update, you need to do two things.
1. Add a sentence to the sender Activity

PendingIntent pendingIntent = PendingIntent.getActivity(context,0,intent,PendingIntent.FLAG_UPDATE_CURRENT);  

2. The receiving Activity, plus a function, calls the method setIntent

protected void onNewIntent(Intent intent) {
  Log.i(TAG,"onNewIntent()");
  super.onNewIntent(intent);
  setIntent(intent);
  int value = getIntent().getIntExtra("value_key", 0);
  Log.i(TAG,"value = "+value);
}

Reproduced in: https://www.cnblogs.com/davesuen/p/3703436.html

Solution for iPhone wechat flash back with mysterious code

On the night of the 14th, many people appeared in their WeChat Momentals such as “When you click the full text on an iPhone, it will flash back.” There were several blank lines below, so you need to click “full text” to see it. However, once you click “original” on an iPhonWeChatB1, it will flash back directly, while there is no problem with Android phones.

In fact, there is a set of code hidden below this article, which is only available for iOS. But fortunately, this is just a flash back, will not appear WeChat can not open the situation. This is the code from two years ago. If an iPhone user receives this code, it will cause WeChat, Twitter, SMS, and other apps to crash or crash. The code exploits an iOS remote denial of service vulnerability, which has since been fixed, but now a new code has appeared that causes WeChat to flash back when the iPhone is turned on.)
WeChat ->; “I” – & gt; ‘My photo album’ -> Click “today” on the camera there and send a picture to restore it.
There is another method for flashback in Moments, you can clean up the WeChat cache in WeChat Settings – General, this operation will clear the Moments cache, can be restored, if click the Moments flashback again, it is proved that your friends have sent flashback characters.

An example of drawing rotating cube with OpenGL

In the last section, we learned how to use OpenGL to draw 2D graphics. Now let’s learn how to use OpenGL to draw 3D graphics. Let’s really feel the power of OpenGL
In the last video we drew a rotating triangle and square, today we’re going to use OpenGL to draw a rotating cube.
Drawing cubes is basically the same as drawing triangles and squares. The key is to build the coordinates of cubes. When building these vertex coordinates, to rotate the object around its own axis, the object’s center coordinates must always be (0.0f, 0.0f, 0.0f) and drawn in counterclockwise order.
Without further ado, here is an example:
Start by creating an OpenGLView class that inherits GLSurfaceView
public class OpenGLView extends GLSurfaceView{ private GLReader glReader; public OpenGLView(Context context) { super(context); // TODO Auto-generated constructor stub glReader=new GLReader(); setRenderer(glReader); }}
Next is our Activity class:
public class SimpleOpenGLActivity extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); OpenGLView view=new OpenGLView(this); setContentView(view); }}
Finally, our core class, the GlReader class for rendering 3D graphics, implements the Renderer interface:
package cn.com.karl.opengl; import java.nio.ByteBuffer; import java.nio.ByteOrder; import java.nio.FloatBuffer; import java.nio.IntBuffer; import javax.microedition.khronos.egl.EGLConfig; import javax.microedition.khronos.opengles.GL10; import javax.microedition.khronos.opengles.GL11; import android.opengl.GLSurfaceView.Renderer; import android.opengl.GLU; Public class GLReader implements the Renderer {float box [] = new float [] {//FRONT – 0.5 f to 0.5 f to 0.5 f to 0.5 f to 0.5 f to 0.5 f to 0.5 f to 0.5 f to 0.5 f to 0.5 f to 0.5 f to 0.5 f,// BACK to 0.5 f to 0.5 f to 0.5 f to 0.5 f to 0.5 f, 0.5 f, f, 0.5-0.5 f to 0.5 f to 0.5 f to 0.5 f to 0.5 f,// LEFT – 0.5 f to 0.5 f to 0.5 f to 0.5 f to 0.5 f to 0.5 f to 0.5 f to 0.5 f to 0.5 f to 0.5 f to 0.5 f to 0.5 f,// RIGHT f 0.5, – 0.5 f to 0.5 f, f 0.5, 0.5 f to 0.5 f, 0.5 f to 0.5 f, 0.5 0.5 f, f, f 0.5, 0.5, f// TOP – 0.5 f, 0.5 f, f, 0.5 0.5 f, f 0.5, 0.5 f to 0.5 f, 0.5 f to 0.5 f, f 0.5, 0.5 f to 0.5 f,// BOTTOM – 0.5 f, 0.5 f, f, 0.5-0.5, f – 0.5 f to 0.5 f, 0.5 f to 0.5 f, f 0.5, 0.5, f – 0.5 f to 0.5 f,}; FloatBuffer cubeBuff; Float xrot = 0.0 f; Float yrot = 0.0 f;/* * * to convert a float array is stored in the byte array buffer * @ param arr * @ return */public FloatBuffer makeFloatBuffer (float [] arr) {ByteBuffer bb = ByteBuffer. AllocateDirect (arr. Length * 4); B.order (byteOrder.nativeOrder ()); b.order(); // Set ByteOrder, where byteOrder.nativeOrder () is to get the native ByteOrder FloatBuffer fb = bb.asFloatBuffer(); // Convert to float fb.put(arr); // Add data fb.position(0); Return fb; return fb; } public GLReader(){ cubeBuff = makeFloatBuffer(box); }//// conversion float array all drawing operations are carried out in this method the public void onDrawFrame GL10 (gl) {//TODO Auto – generated method stub gl. GlClear (GL10. GL_COLOR_BUFFER_BIT | GL10. GL_DEPTH_BUFFER_BIT); // Clear the screen and depth cache gl.glMatrixMode(gl10.gl_ModelView); // Switch to the model observation matrix gl.glLodIdentity (); // Reset the current model observation matrix Glu. GluLookAt (GL, 0, 0, 3, 0, 0, 0, 0, 0, 1, 0); // Set the viewpoint and model center position gl.glTexPointer (3, gl10.gl_float, 0, cubeBuff); // Set vertex data gl. glenableClientState (gl10.gl_vertex_array); gl.glRotatef(xrot, 1, 0, 0);// around the (0, 0) and (0, 1). The x axis rotation gl glRotatef (yrot, 0, 1, 0). GlColor4f (1.0f, 0, 0, 1.0f); glColor4f(1.0f, 0, 0, 1.0f); // Set color, red gl.glDraWarRays (gl10.gl_triangle_strip, 0, 4); // draw square FRONT gl.glColor4f(1.0f, 1.0f, 0, 1.0f); gl.glDrawArrays(GL10.GL_TRIANGLE_STRIP, 4, 4); Gl. GlColor4f (0, 1.0 f, 0, 1.0 f); gl.glDrawArrays(GL10.GL_TRIANGLE_STRIP, 8, 4); Gl. GlColor4f (0, 1.0 f, f 1.0, 1.0 f); gl.glDrawArrays(GL10.GL_TRIANGLE_STRIP, 12, 4); Gl. GlColor4f (0, 0, 1.0 f, 1.0 f); gl.glDrawArrays(GL10.GL_TRIANGLE_STRIP, 16, 4); Gl. GlColor4f (1.0 f, f, 1.0 1.0 f, 1.0 f); gl.glDrawArrays(GL10.GL_TRIANGLE_STRIP, 20, 4); Xrot + = 1.0 f; Yrot + = 0.5 f; } public void onSurfaceChanged(GL10 gl, int width, int height) {// TODO auto-generated method stub // set the scene size of OpenGL. GlViewport (0, 0, width, height); gl.glMatrixMode(GL10.GL_PROJECTION); // Set the projection matrix gl.glLodIdentity (); Glu.gluPerspective (gl, 45.0f, ((float) width)/height, 0.1f, 10f); Public void onSurfaceCreated(gl10gl, eGLConfig config) {// TODO Auto-generated method stub gl.glclearColor (0.0f, 0.0f, 0.0f, 1.0f); // Set the background color to R, G, B, A gl.glEnable(gl10.gl_depth_test); // Enable depth cache gl.glEnable(gl10.gl_cull_face); // Enable backside clipping gl.glclearDepthf (1.0f); // Set the depth cache value gl.glDepthFunc(gl10.gl_lequal); GL_LEQUAL (gl.glclearDepthf (1.0f)); gl.glshaDemodel (gl10.gl_smooth); gl.glclearDepthf (1.0f); gl.glclearDepthf (1.0f);// set the shadow model GL_SMOOTH}}
the upper portion of the more important is to do the comments, so here don’t do too much explanation, finally see how some after the operation effect.

Problems in the second day of Android learning

The blogger uses Android Studio, installs the APK into the emulator, runs the first time, uninstalls, and then runs the second time to re-issue the question:
Error type 3
Error: Activity class {com.example.xx.chap2_2/com.example.xx.chap2.FirstActivity} does not exis

Analysis of the problem, I don’t know (to be answered later). Obviously, the uninstallation on the simulator has been finished, the blogger guessed that it should be the simulator problem, there is no such problem when installing the blogger on the real machine.
Modify the package name ApplicationID in the app’s build.gradle and rerun it.
 

Reproduced in: https://www.cnblogs.com/listentothecloud20150215/p/10053915.html