Tag Archives: android

[Solved] com.android.dex.DexIndexOverflowException: method ID not in [0, 0xffff]: 65536

At the same time, multiple third-party jar packages were introduced into the project, which caused the number of methods to be called to exceed 65536 set by android (DEX 64K problem), which caused the dex to be unable to be generated, and thus the APK file could not be generated.

The solution is as follows:

1. Google has officially given relevant documents, referring to the information searched on the Internet. First of all, my question is:

Error:Execution failed for task ':duchazhushou:dexRelease'.
> com.android.ide.common.internal.LoggedErrorException: Failed to run command:
    C:\Users\jeff\AppData\Local\Android\sdk\android-sdk\build-tools\21.1.1\dx.bat --dex --output D:\dev\android\Duchazhushou_TDT\duchazhushou\build\intermediates\dex\release --input-list=D:\dev\android\Duchazhushou_TDT\duchazhushou\build\intermediates\tmp\dex\release\inputList.txt
Error Code:
    2
Output:
    UNEXPECTED TOP-LEVEL EXCEPTION:
    com.android.dex.DexIndexOverflowException: method ID not in [0, 0xffff]: 65536
        at com.android.dx.merge.DexMerger$6.updateIndex(DexMerger.java:502)
        at com.android.dx.merge.DexMerger$IdMerger.mergeSorted(DexMerger.java:277)
        at com.android.dx.merge.DexMerger.mergeMethodIds (DexMerger.java: 491 )
        at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:168)
        at com.android.dx.merge.DexMerger.merge (DexMerger.java: 189 )
        at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:454)
        at com.android.dx.command.dexer.Main.runMonoDex(Main.java:302)
        at com.android.dx.command.dexer.Main.run(Main.java:245)
        at com.android.dx.command.dexer.Main.main(Main.java:214)
        at com.android.dx.command.Main.main(Main.java:106)

2. Add sub-package settings in the dependencies section of the project’s build.gradle file:

dependencies { 
... 
   compile 'com.android.support:multidex:' 
   ... 
}

3. Enable multi-dexing support by setting the multiDexEnabled tag to true in the defaultConfig section.

defaultConfig { 
   ... 
multiDexEnabled true 
... 
}

4. There are three cases. Since I did not create my own Application.class, I added it directly to the Application declaration in the AndroidManifest.xml file;

android:name="android.support.multidex.MultiDexApplication"

5. Rebuild, generate signed APK, install and use normally.

[Run the android emulator] emulator: ERROR: x86 emulation currently requires hardware acceleration!

Run Android emulator, emulator: error: x86 emulation currently requires hardware acceleration

Question:

Run Android emulator, emulator: error: x86 emulation currently requires hardware acceleration

Analysis:

The computer does not have virtual technology enabled or Intel haxm software installed

Solution:

1. Make sure that the virtual technology in configuration in BIOS is enabled

The general way to enter BIOS is to press and hold F2 (F12) when the computer restarts, and set Intel virtual technology to enable state, as shown in the following figure:

2. Download Intel haxm software

Steps:

Step 1: open “Android Studio – SDK manager”, as shown in the following figure:

Step 2: select “Android SDK” on the right, click “SDK tools”, and then select “Intel x86 emulator accelerator (haxm installer)” to install, as shown in the following figure:

Step 3: view and install Intel haxm

The software downloaded just now is placed in “SDK path – Extras – Intel – hardware”_ Accelerated_ Execution_ Manager, as shown in the figure below:

Step 4: Click to install “Intel haxm-android.exe”, as shown in the following figure:

Step 5: start andorid Studio – AVD manager, as shown in the following figure:

Open the simulator, as shown in the following figure:

Android——connect failed: EHOSTUNREACH (No route to host)

Android error — Connect failed: ehostunreach (no route to host)

There is no route to connect to the host
when testing on a real machine, I encountered this problem. I saw a method on the Internet, restart the mobile phone. If it is not possible to restart the router, restart all the ones that can be restarted…
refer to the article
for details http://www.tuicool.com/articles/Une2qq

The Android compiler appears execution failed for task ‘: app:processDebugResources ‘.

With multi-dimensional model as the core, let the factory digital transformation and upgrading “within reach”>>>

The Android compiler appears org.gradle.api.tasks.taskexecutionexception: execution failed for task ‘: app:processDebugResources ‘wrong

how to deal with
open the terminal of Android studio and enter the command at the command line: gradlew compiledebugsource -- stacktrace - info or gradlew assembledebug -- info

On Android, getactionbar () always returns null. Or related issues

How is 618 sales champion made?Uncover the secret of e-commerce’s “invigorating” hundreds of millions of sales data>>>

1) Settings

< uses-sdk android:minSdkVersion= “4” android:targetSdkVersion= “11” />

This indicates that the application can be deployed on Android 3.0 or before. In other words, when the device’s sdkversion = = 11, the application will start the action bar

We need to set minsdkversion to 11 . Otherwise, your action will not appear

There are also some funny ones

getWindow().requestFeature(Window.FEATURE_ ACTION_ BAR);

You can get the actionbar out with this sentence, but the position of actionbar is black

Or in Android 8.0

getWindow().requestFeature(8);

They all have the same effect, so… Want to use mobile phones below sdk11

Don’t use actionbar, or there will be a lot of bugs

[Solved] Android Warning: Gradle DSL method not found: ‘android()’

This problem is caused by the Android attribute in the build.gradle file under project. Under normal circumstances, there are only three attributes in the build.gradle file under Project: buildscript, allprojects and dependencies (which are empty in many cases)

The contents are as follows:

// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {

    repositories {
        jcenter()
    }

    //Configure gradle version
    dependencies {
        classpath 'com.android.tools.build:gradle:1.3.0'
    }
}
allprojects {
    repositories {
        jcenter()
    }
}

dependencies {
}

Android Project Error: Invoke-customs are only supported starting with Android O (–min-api 26)

Android project error: invoke customers are only supported starting with Android o (- – min API 26)

Solution:

Under the app folder, click build. Gradle

compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
  targetCompatibility JavaVersion.VERSION_1_8
}

As shown in the figure below

Android: installation error: install_ FAILED_ UPDATE_ Incompatible solution

Why can’t you stop buying 618?From the technical dimension to explore>>>

record a delete_ FAILED_ INTERNAL_ Error error while installing apk

I met this problem before

Option 1

Delete the directory of the package name of the application under the data/data/directory, such as: ADB shell RM – RF data/data/com.demo.helloworld/

Then restart the phone

Or just turn off instant run

When the new version of Android studio runs APK, delete appears_ FAILED_ INTERNAL_ Error, error while installing apks
there is a way: open settings and find build > Instant run, remove the tick on the right and try to install again

Option 2:

Step 1: delete the existing APK with the same package name, such as ADB shell RM system/APP/outdoormeter/outdoormeter.apk

Step 2: delete the directory of the package name of the application under the data/data/directory, such as: ADB shell RM – RF data/data/com. Runbo. Outdoormeter/

Step 3: restart the Android mobile ADB reboot

Step 4: re install the APK

Reference address

http://blog.csdn.net/ouyang_ peng/article/details/50419276

https://stackoverflow.com/questions/38892270/delete-failed-internal-error-error-while-installing-apk

How to Solve Android Error: java.lang.SecurityException: Permission Denial

Record an error encountered in daily development: java. Lang. SecurityException: permission denial: startforeground from PID = 2345, uid = 10395 requires Android. Permission. Foreground_ SERVICE.

This error mainly appears on Android 9.0 phones, because Android 10 has no coverage

Solutions

<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />

The above error is due to Android 9.0’s new restrictions on permissions. This foreground service permission needs to be statically applied in the androidmanifest.XML file. Adding the above permission code will not report an error

 

Android Exception: UncaughtException detected: java.lang.RuntimeException: Parcelable encountered IOExcepti

Exception information:
uncaughtexception detected: java.lang.runtimeexception: separable accounted IOException writing serializable object

causes

When transferring data between activities, there is a problem in implementing serializable interface

Entity class



public class GoodsBean implements Serializable {

    private String createtime;
    private String images;
    private int clickCount;
    private UniUserBean uniUser;
    private String mobile;
    private String description;
    private int catId;
    private int createid;
    private double price;
    private String name;
    private int id;
    private int status;

Second Activity

    private void exit4Goods(int position) {
        if (mGoodLists != null) {
            GoodsBean goodsBean = mGoodLists.get(position);
            Intent data = new Intent();

            data.putExtra("goodsBean", goodsBean);

            setResult(ConstantValues.ACTIVITY_SELECT_GOODS_SUCCESS_CODE, data);
        }
    }

First Activity

 if (resultCode == ConstantValues.ACTIVITY_SELECT_GOODS_SUCCESS_CODE) {
            if (data != null) {
                GoodsBean goodsBean = (GoodsBean) data.getSerializableExtra("goodsBean");
            }
        }

solutions

The entity class goodsbean refers to the uniuserbean, so we should not only serialize the goodsbean, but also the uniuserbean