Tag Archives: Android

How to Solve Error while executing: am start -n

When Android studio installs and debugs APK, the compilation passes, but when debugging and installing online, it will report an error while executing: am start – N error

The ADB uninstall package name is not used

After searching for a long time, I found that the installation options in edit configuration were set to nothing before. When running, it will not automatically PM install

Change to default APK as follows

Apktool back compilation error [How to Solve]

report errors

error: No resource identifier found for attribute 'XXX' in package 'XXX'

Solution:

Save the XML file to “ http://schemas.android.com/apk/res-auto " changed to " http://schemas.android.com/apk/lib/com.app.chasebank "

other

I directly used Android killer for back compilation. There were more than 10 errors at once. It was too troublesome to change one by one, so I simply wrote a python script:

import os
import re

file = "error.txt"

def change_content(file):
    if os.path.exists(file):
        with open(file) as f:
            content = f.read()
        if "http://schemas.android.com/apk/res-auto" in content:
            print(file+":已修复")
            content = content.replace("http://schemas.android.com/apk/res-auto","http://schemas.android.com/apk/lib/com.app.chasebank")
            with open(file,"w") as f:
                f.write(content)

with open(file,encoding='utf8') as f:
    data = f.read()

result = re.findall(">W: (.*?):\d+: error: No resource identifier found for attribute",data)
for file in result:
    change_content(file)

Copy the error to the error.txt file, and then run the script to modify the XML file directly.

Sometimes, such errors will appear in the back compilation. You may need to copy the errors again and then execute the script. That is to say, some errors are not reported because the previous errors have not been solved, and all such errors cannot be reported at one time.

How to Solve Jetpack room use error

 

When building the room, there are several small problems. Record them. Basically, it is a configuration problem:

There is a problem with the query: [SQLITE_ERROR] SQL error or missing database (no such table: simple_student)。
an error is reported during compilation and the table cannot be found
you need to set the corresponding indication in the declared entity.

//Wrong
@Entity
data class StudentEntity
//Right
@Entity(tableName = "student_table")
data class StudentEntity

Not sure how to convert a Cursor to this method’s return type (kotlinx.coroutines.flow.Flow<?extends java.util.List<com.zxf.jetpackrelated.room.liveDataOrFlow.StudentEntity>>).

When the Dao layer declares the return value as livedata, an error is reported. After a long investigation, it was found that the corresponding function was declared as a suspended function
correct use should remove the corresponding suspend modifier.

//Wrong
@Query("select * from $STUDENT_TABLE_NAME")
suspend fun obtainStudentAll(): LiveData<List<StudentEntity>>
//Right
@Query("select * from $STUDENT_TABLE_NAME")
fun obtainStudentAll(): LiveData<List<StudentEntity>>

Not sure how to convert a Cursor to this method’s return type (androidx.lifecycle.LiveData<java.util.List<com.zxf.jetpackrelated.room.liveDataOrFlow.StudentEntity>>)
Similarly, it cannot be converted to flow, and the corresponding suspend modifier is removed.

//Wrong
@Query("select * from $STUDENT_TABLE_NAME")
suspend fun obtainStudentAll(): Flow<List<StudentEntity>>
//Right
@Query("select * from $STUDENT_TABLE_NAME")
fun obtainStudentAll(): Flow<List<StudentEntity>>

If you do not need to declare the return type as livedata or flow, you can directly declare suspend.

Android 10: How to Solve Systemui Error

1、 The following error is reported in the single compilation systemui:

eworks/base/packages/SystemUI/SystemUI-tests/android_common/javac/srcjars"
frameworks/base/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/KeyguardBouncerTest.java:382: Error: Symbol not found
        when(mUnlockMethodCache.isUnlockingWithFacePossible()).thenReturn(true);
                               ^
  Symbol: method isUnlockingWithFacePossible()
  Location: Variable of type UnlockMethodCache mUnlockMethodCache
frameworks/base/packages/SystemUI/tests/src/com/android/systemui/utils/leaks/FakeHotspotController.java:22: Error: FakeHotspotController is not abstract, and does not override the abstract method isHotspotEnabling() in HotspotController
public class FakeHotspotController extends BaseLeakChecker<Callback> implements HotspotController {
       ^
Note: Some input files use or override deprecated APIs.
Note: For more information, please recompile with -Xlint:deprecation.
Note: Some input files use unchecked or unsafe operations.
Note: For more information, please recompile with -Xlint:unchecked.
2 errors
16:19:16 ninja failed with: exit status 1

Reason:
the error in tests may be the reason why Google has not updated it, so the whole system will not prompt an error during compilation. This error does not affect the subsequent use of
solutions:
error 1: isunlockingwithfacepossible() directly modifies the place where the method is called to false
error 2: the method is not rewritten ishhotspotenabling()
fakehotspotcontroller rewrites the ishhotspotenabling() method in this class

 @Override
    public boolean isHotspotEnabling() {
        return false;
    }

[Solved] Unity Package Error: FAILURE: Build failed with an exception.

Main error reports:

> Using multiple versions of the Android gradle plugin in the sample build is not allowed.
meaning: using multiple versions of the Android gradle plugin in the same version is not allowed.

positioning:
gradle version problem in
unit

Solution:
there is a gradle version file in the project
launchertemplate
maintemplate
find a code similar to the following

buildscript {
    repositories {
        mavenCentral()
        google()
        jcenter()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:3.4.3'
**BUILD_SCRIPT_DEPS**}

If not, add
as shown in the figure

to ensure that the version numbers (3.4.3) in the two files are consistent

Gradlew compilation error: mips64el Linux Android strip

Known configuration

ndk.dir=/home/.../Sdk/ndk-bundle  
sdk.dir=/home/.../Sdk  

Gradlew compilation error

Execution failed for task ':app:transformNativeLibsWithStripDebugSymbolForxxxxx'.
> A problem occurred starting process 'command '\
<sdk.dir>/ndk-bundle/toolchains/mips64el-linux-android-4.9/prebuilt/linux-x86_64/bin/mips64el-linux-android-strip''

View Android/SDK installation path

$ ll <sdk.dir>/ndk-bundle/toolchains/
drwxrwxrwx  3 lily lily 4096 aarch64-linux-android-4.9/
drwxrwxrwx  3 lily lily 4096 arm-linux-androideabi-4.9/
drwxrwxrwx  3 lily lily 4096 llvm/
lrwxrwxrwx  1 lily lily   25 mips64el-linux-android-4.9 -> aarch64-linux-android-4.9/
lrwxrwxrwx  1 lily lily   25 mipsel-linux-android-4.9 -> arm-linux-androideabi-4.9/
drwxrwxrwx  3 lily lily 4096 renderscript/
drwxrwxrwx  3 lily lily 4096 x86-4.9/
drwxrwxrwx  3 lily lily 4096 x86_64-4.9/

I downloaded an extra version of NDK R15, android-ndk-r15c

To change to

$ ll <sdk.dir>/ndk-bundle/toolchains/
drwxrwxrwx  3 lily lily 4096 aarch64-linux-android-4.9/
drwxrwxrwx  3 lily lily 4096 arm-linux-androideabi-4.9/
drwxrwxrwx  3 lily lily 4096 llvm/
lrwxrwxrwx  1 lily lily 84 mips64el-linux-android-4.9 -> <sdk.dir>/ndk/android-ndk-r15c/toolchains/mips64el-linux-android-4.9/
lrwxrwxrwx  1 lily lily 82 mipsel-linux-android-4.9 -> <sdk.dir>/ndk/android-ndk-r15c/toolchains/mipsel-linux-android-4.9/
drwxrwxrwx  3 lily lily 4096 renderscript/
drwxrwxrwx  3 lily lily 4096 x86-4.9/
drwxrwxrwx  3 lily lily 4096 x86_64-4.9/

In this way, there is no error in compilation

No toolchains found in the NDK toolchains folder for ABI with prefix

Encountered internal error running command: Error: Error occured while starting App. Original error:

Error: Encountered internal error running command: Error: Error occured while starting App. Original error: Error executing adbExec
[ADB] Error: Error occured while starting App. Original error: Error executing adbExec. Original error: ‘Command ‘C\:\\Users\\bo_\\AppData\\Local\\Android\\Sdk\\platform-tools\\adb.exe -P 5037 -s 127.0.0.1\:62001 shell am start -W -n

An unknown server-side error occurred while processing the command. Original error: Error occured while starting App. Original error: Error executing adbExec. Original error: ‘Command ‘C\:\\Users\\bo_\\AppData\\Local\\Android\\Sdk\\platform-tools\\adb.exe -P 5037 -s 127.0.0.1\:62001 shell am start -W -n com.eg.android.AlipayGphone/com.eg.android.AlipayGphone.AlipayLogin -S’ timed out after 20000ms’; Stderr: ”; Code: ‘null’ (WARNING: The server did not provide any stacktrace information

1. First check if the local app can be opened
2. See if the DesiredCapabilities configuration is normal

First look at the activity, using the command
Open the app under test and enter the command adb shell dumpsys window | findstr mCurrentFocus
Start the app under test and enter the command
>adb shell dumpsys activity activities >E:\aaa.txt

Aapt Remove Command error during crunch – archive is toast

To package APK these days, you need to use the AAPT command to remove the old certificate file in APK, add a new certificate file again, and then sign and repackage again. It is found that when using the AAPT remove command, the error during crash – archive is toast is always reported. After a day’s comparison, it is found that it is related to the referenced com.android.tools.build: gradle: 4.1.1 and gradle-6.5-bin versions. As long as it is equal to or greater than this version, this error will be reported, which should be a bug of AAPT.

Solution:

1. The gradle plug-in is lower than these two versions. It’s unrealistic. It’s impossible not to upgrade it all the time.

2. Since APK is essentially a zip file, simply when deleting the file, open the APK package directly with the zip decompression software, manually delete the ball, and complete the remaining AAPT add command and re signature operation with the command line.

[Solved] Fluent filesysterexception: exists failed, path =’d: \ as’. Plugins’ (OS error: incorrect file name, directory name or volume slogan)

E:\flutter_project\first_app>flutter doctor -v
[√] Flutter (Channel stable, 2.2.3, on Microsoft Windows [Version 10.0.19042.1052], locale zh-CN)
    • Flutter version 2.2.3 at D:\flutter
    • Framework revision f4abaa0735 (7 days ago), 2021-07-01 12:46:11 -0700
    • Engine revision 241c87ad80
    • Dart version 2.13.4

[√] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
    • Android SDK at D:\Android
    • Platform android-30, build-tools 30.0.3
    • ANDROID_HOME = D:\Android
    • Java binary at: D:\Java\jdk\bin\java
    • Java version Java(TM) SE Runtime Environment (build 1.8.0_231-b11)
    • All Android licenses accepted.

[√] Chrome - develop for the web
    • Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe

[☠] Android Studio (the doctor check crashed)
    X Due to an error, the doctor check did not complete. If the error message below is not helpful, please let us know
      about this issue at https://github.com/flutter/flutter/issues.
    X FileSystemException: Exists failed, path = ''D:\AS'.plugins' (OS Error: 文件名、目录名或卷标语法不正确。
      , errno = 123)
    • #0      _Directory.existsSync (dart:io/directory_impl.dart:94:7)
      #1      ForwardingFileSystemEntity.existsSync
      (package:file/src/forwarding/forwarding_file_system_entity.dart:43:33)
      #2      ErrorHandlingDirectory.existsSync.<anonymous closure>
      (package:flutter_tools/src/base/error_handling_io.dart:479:22)
      #3      _runSync (package:flutter_tools/src/base/error_handling_io.dart:573:14)
      #4      ErrorHandlingDirectory.existsSync (package:flutter_tools/src/base/error_handling_io.dart:478:12)
      #5      AndroidStudio.pluginsPath (package:flutter_tools/src/android/android_studio.dart:186:52)
      #6      AndroidStudioValidator.validate (package:flutter_tools/src/android/android_studio_validator.dart:46:17)
      #7      asyncGuard.<anonymous closure> (package:flutter_tools/src/base/async_guard.dart:111:32)
      #8      asyncGuard.<anonymous closure> (package:flutter_tools/src/base/async_guard.dart:109:18)
      #9      _rootRun (dart:async/zone.dart:1354:13)
      #10     _CustomZone.run (dart:async/zone.dart:1258:19)
      #11     _runZoned (dart:async/zone.dart:1789:10)
      #12     runZonedGuarded (dart:async/zone.dart:1777:12)
      #13     runZoned (dart:async/zone.dart:1708:12)
      #14     asyncGuard (package:flutter_tools/src/base/async_guard.dart:109:3)
      #15     Doctor.startValidatorTasks (package:flutter_tools/src/doctor.dart:199:9)
      #16     Doctor.diagnose (package:flutter_tools/src/doctor.dart:303:47)
      #17     DoctorCommand.runCommand (package:flutter_tools/src/commands/doctor.dart:50:47)
      #18     FlutterCommand.verifyThenRunCommand (package:flutter_tools/src/runner/flutter_command.dart:1192:12)
      <asynchronous suspension>
      #19     FlutterCommand.run.<anonymous closure> (package:flutter_tools/src/runner/flutter_command.dart:1043:27)
      <asynchronous suspension>
      #20     AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19)
      <asynchronous suspension>
      #21     CommandRunner.runCommand (package:args/command_runner.dart:196:13)
      <asynchronous suspension>
      #22     FlutterCommandRunner.runCommand.<anonymous closure>
      (package:flutter_tools/src/runner/flutter_command_runner.dart:284:9)
      <asynchronous suspension>
      #23     AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19)
      <asynchronous suspension>
      #24     FlutterCommandRunner.runCommand (package:flutter_tools/src/runner/flutter_command_runner.dart:232:5)
      <asynchronous suspension>
      #25     run.<anonymous closure>.<anonymous closure> (package:flutter_tools/runner.dart:62:9)
      <asynchronous suspension>
      #26     AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19)
      <asynchronous suspension>
      #27     main (package:flutter_tools/executable.dart:91:3)
      <asynchronous suspension>


[√] IntelliJ IDEA Community Edition (version 2021.1)
    • IntelliJ at D:\Intelij\IntelliJ IDEA Community Edition 2021.1.2
    • Flutter plugin can be installed from:
       https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
       https://plugins.jetbrains.com/plugin/6351-dart

[√] VS Code (version 1.57.1)
    • VS Code at C:\Users\zhongdongjing\AppData\Local\Programs\Microsoft VS Code
    • Flutter extension can be installed from:
       https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter

[√] Connected device (2 available)
    • Chrome (web) • chrome • web-javascript • Google Chrome 91.0.4472.124
    • Edge (web)   • edge   • web-javascript • Microsoft Edge 91.0.864.64

! Doctor found issues in 1 category.

Run fluent config -- Android studio dir = "C:\program files\Android\Android studio" this problem occurs if the path of Android studio cannot be found. Make sure to use the correct Android studio path.

Run fluent doctor again