Tag Archives: Android

[Solved] Android Room: Database Common Error ‘missing database’

Common error 1:

D:\AndroidProjectsDemo\JetpeckTest\app\build\tmp\kapt3\stubs\debug\com\example\jetpecktest\room\BookDao.
java:15: error: There is a problem with the query: [SQLITE_ERROR] 
SQL error or missing database (no such table: BookEntity)
public abstract java.util.List<com.example.jetpecktest.room.BookEntity> loadAllBooks();

**Solution: * * the error report mentions no such table: bookentity , so first check whether your class is added to the database, that is, check the entities =?In the
annotation in your database class
did you add your entity class.

@Database(version = 2, entities = [BookEntity::class])
abstract class DataBase:RoomDatabase() {

[Solved] Android Networking error: CLEARTEXT communication to www.xxxxx.xyz not permitted by network security policy

Question

Android networking error: cleartext communication to www.xxxxx.xyz not allowed by network security policy

Question

After targetsdkversion26, for security reasons, Google requires encrypted connections for Android applications, so an error will be reported when using HTTP for network access

Solution:

1. Targetsdkversion dropped below 27

Pre connect unencrypted before targetsdkversion 27

2. Modify the androidmanifest.xml configuration file

Add the following attributes in the application tab

    android:usesCleartextTraffic="true"

errorCode:9015,errorMsg:cn.bmob.v3.util.BmobContentProvider.updateProvider(BmobContentProvider.java:

About the 9015 null pointer in the bmob backend cloud service platform, I checked it online. The reason is very simple, that is, it does not operate according to the official documents. Although the data can still be transmitted normally, it is still annoying to open the app with a prompt pop-up window.

Solution:

Directly open androidmanifest.xml and add two lines of code

        <provider
            android:name="cn.bmob.v3.util.BmobContentProvider"
            android:authorities="com.example.login.BmobContentProvider"/>

If I can help you, just give me a favor!!!   Thank you from the majority of hard pressed programmers!

Does flutter report an error after upgrading 2.5?

Q:

After the flutter executes the command to upgrade the new version, there are the following problems when checking with the flutter doctor command:

After typing the command according to the prompt, an error message appears again:

A:
after we upgrade the SDK, execute fluent doctor , which prompts us to install the command line tools developed by Android. When we install the command line tool according to the prompt, the Java error is generally because we have installed a set of java version locally, but the Java version number is higher than 1.8, resulting in compatibility problems.

There are two ways to solve the problem. The first is to uninstall our own installed Java and reinstall a lower version of Java (1.8), but it is not recommended!

Since Android development can only use java version 1.8, the Android Studio development environment will bring its own Java virtual machine, so we don’t need to install an independent Java environment ourselves. Therefore, we actually don’t need to pay attention to our locally installed java version. We can directly open the Android studio tool and automatically install CmdLine tools :

As shown in the figure above, check the tool and click OK to install it automatically. After installation, re execute the fluent doctor command to solve the problem!


Official account: programming path from 0 to 1

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)

android studio:Error inflating class android.support.v4.widget.SwipeRefreshLayout

We just need to add the custom components of XML

Android.support.v4.widget.swiperefreshlayout is changed to:

androidx.swiperefreshlayout.widget.SwipeRefreshLayout

At the same time, the most important thing is to rely on it. This will not be reported wrong. I found it only after looking for someone else’s blog

implementation ‘androidx.swiperefreshlayout:swiperefreshlayout:1.0.0’
 

[Solved] error: external/googletest/googletest: MODULE.TARGET.STATIC_LIBRARIES.libgtest already defined

Android9.0 System compilation error
170/978] including external/google-tv-pairing-protocol/Android.mk …
[171/978] including external/googletest/Android.mk …
build/make/core/base_rules.mk:260: error: external/googletest/googletest: MODULE.TARGET.STATIC_LIBRARIES.libgtest already defined by external/googletest/googletest.
09:42:55 ckati failed with: exit status 1
0;31m#### failed to build some targets (49 seconds) ####
The reason of the error
The compiler server has defined NDK_ROOT environment variable, which conflicts with Android compiler environment variable.
Check whether NDK_ROOT environment variable or SDK_ROOT environment variable is defined.

echo $NDK_ROOT

My compilation server defines NDK_Root environment variable, so echo $NDK_Root outputs the following path:
/xxx_NDK_Root/
indicates that the change amount is defined.

Solution:

Remove the environment variable temporarily

export NDK_ROOT=""

Continue to compile the system.

[Solved] Error: Cannot fit requested classes in a single dex file (# methods: 149346 > 65536)

Any jar file that references a third-party library may trigger this error. The solution is as follows:

1. Add dependencies in build.gradle of app, and add the following code in defaultconfig [Note: it must be the module of app, not other modules]

apply plugin: 'com.android.application'

android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "com.why.project.poidemo"
        minSdkVersion 16
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

        //
        multiDexEnabled true
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

    //poi
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
}

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    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:multidex:1.0.3'
}

2. If you customize the application subclass, you need to override a method in this subclass

@Override
public void onCreate() {
    super.onCreate();
    // add the line as below
    MultiDex.install(this);
}

AAPT: error: attribute cardBackgroundColor (aka com.x.x:cardBackgroundColor) not found.

* What went wrong:
Execution failed for task ':launcher:processReleaseResources'.
> Android resource linking failed
  C:\Users\Administrator\.gradle\caches\transforms-2\files-2.1\a3890adfdb75cc00c9c342ba929acf1b\res\layout\com_facebook_device_auth_dialog_fragment.xml:22: AAPT: error: attribute cardBackgroundColor (aka com.test.k22:cardBackgroundColor) not found.
      
  C:\Users\Administrator\.gradle\caches\transforms-2\files-2.1\a3890adfdb75cc00c9c342ba929acf1b\res\layout\com_facebook_device_auth_dialog_fragment.xml:22: AAPT: error: attribute cardElevation (aka com.test.k22:cardElevation) not found.
      
  C:\Users\Administrator\.gradle\caches\transforms-2\files-2.1\a3890adfdb75cc00c9c342ba929acf1b\res\layout\com_facebook_smart_device_dialog_fragment.xml:22: AAPT: error: attribute cardBackgroundColor (aka com.test.k22:cardBackgroundColor) not found.
      
  C:\Users\Administrator\.gradle\caches\transforms-2\files-2.1\a3890adfdb75cc00c9c342ba929acf1b\res\layout\com_facebook_smart_device_dialog_fragment.xml:22: AAPT: error: attribute cardElevation (aka com.test.k22:cardElevation) not found.

https://mvnrepository.com/artifact/androidx.cardview/cardview/1.0.0

Download cardview-1.0.0.aar and import it into Assets/Plugins/Android directory.

[Solved] OpenCV ERROR: The minSdk version should not be declared in the android manifest file

ERROR: The minSdk version should not be declared in the android manifest file. You can move the version from the manifest to the defaultConfig in the build.gradle file.
Remove minSdkVersion and sync project
Affected Modules: openCVLibrary3415


Solution: Just comment it out and run it again!!!
ERROR: The minSdk version should not be declared in the android manifest file. You can move the version from the manifest to the defaultConfig in the build.gradle file.
Remove minSdkVersion and sync project
Affected Modules: openCVLibrary3415

[Solved] adb shell error: no devices/emulators found

1. Confirm whether it is connected to the simulator: ADB connect XXX

2. Confirm whether the device enters the developer mode (enter settings – about mobile phone/tablet – continuously click the version number)

3. Confirm whether more than one device is connected: ADB devices

If there are multiple devices, you can kill ADB’s service: ADB kill server first

End the process again: taskkill/F/im adb.exe (if it still fails after killing the service, execute the command to end the process)