Tag Archives: Android studio

Request window feature for Android Development( Window.FEATURE_ NO_ Title) does not take effect

What if you want to hide the ActionBar but the requestWindowFeature(window.feature_no_title) doesn’t work?
Reason: because they define the Activity of inherited android. Support. V7. App. AppCompatActivity, AppCompatActivity itself does not support requestWindowFeature (Window. FEATURE_NO_TITLE) cause, can change to inherit the Activity.

Android appears java.lang.NoClassDefFoundError A solution to the error

A few days ago, at the time of reconstructing an Android project, joined the RXJava , RxAndroid , Retrofit to support development response type, and refactor the code, refactoring everything but in running an Java lang. NoClassDefFoundError this error, and in a few test machine shows the name of the class is different also, For example, on MI4, there is no Handler, and on Huawei, there is no OKHttputils class. This is very confusing. After searching Google, we can't find the problem, but on another Samsung test machine, there is no problem, and finally we find that Multidex is the problem.
Some third party libraries were added during the refactoring, which pushed the number of methods in the entire Android application beyond 65535. The following error should occur when packaging

java.lang.IllegalArgumentException: method ID not in [0, 0xffff]: 65536
at com.android.dx.merge.DexMerger$6.updateIndex(DexMerger.java:501)
at com.android.dx.merge.DexMerger$IdMerger.mergeSorted(DexMerger.java:282)
at com.android.dx.merge.DexMerger.mergeMethodIds(DexMerger.java:490)
at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:167)
at com.android.dx.merge.DexMerger.merge(DexMerger.java:188)
at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:439)
at com.android.dx.command.dexer.Main.runMonoDex(Main.java:287)
at com.android.dx.command.dexer.Main.run(Main.java:230)
at com.android.dx.command.dexer.Main.main(Main.java:199)
at com.android.dx.command.Main.main(Main.java:103)

multiDexEnabled true z multiDexEnabled true defaultConfig z multiDexEnabled true Automatically when a method is more than 65535 hit two Dex package named classes. Dex classes2. Dex , some methods were scored the second Dex package, namely the classes2. Dex , resulted in 5.0 the following models can't run the error.
Here's the solution:
1. defaultConfigcode> m>dexEnabled true
is used>enable MultiDex
2. is added in the dependence on the compile 'com. Android. Support: multidex: 1.0.1' support package for 5.0 the following systems
3. If your project already contains the Application class, then let it inherits. Android support. Multidex. MultiDexApplication class, if your Application has inherited the other classes and do not want to do change, so there's another way of using, overwrite attachBaseContext () method:

public class MyApplication extends FooApplication {
    protected void attachBaseContext(Context base) {

Some problems encountered by Android Aidl

Some problems with Android AIDL
(1) Starting Service ** is required after 5.0
An error will be reported if the service is started implicitly (unless Intent. SetPackage (” application package name of the service to be started “) is started implicitly).
Error:(9, 41) No symbol can be found
The reason is that the other class name (Java) file is mixed with aidl’s aidl file in the same directory
Java files have to be placed under the Java file (server package name + Java file).
Error 1
Error: Error converting the bytecode to dex:
Cause: Java. Lang. RuntimeException: Exception parsing classes
Reason package names contain uppercase letters

p>ge com.example.lqm;
package com.example.lqm;
public class User implements Parcelable{
private String id;
privte String name;
… .
The corresponding aidl file is
package com.example.lqm; // This is user. aidl package
parcelable User;

Android studio AAPT: error: attribute android:requestLegacyExternalStorage not found.

AAPT: error: attribute android:requestLegacyExternalStorage not found.
The SDK used in the project is 28. After updating the third-party SDK, the compiler will report an error.
Set compileSdkVersion to 29.


The solution of Android package error

Before, when I was working on the company’s APP, the functions had been fully realized and it could also run normally on the mobile phone, but it kept reporting errors when packaging

\build\intermediates\res\ resources-anzhi-debug-ap_ ‘specified for property ‘resourceFile’ does not exist, so I found a lot of information on the web.
Some say that the version of SDK is lower than the version of ADT. It is suggested to upgrade the SDK version. Some say that an option of the Android Studio setting is removed.
Finally on the net or found a solution to the code, now record.
In fact, we only need to modify the build.gradle code

BuildTypes {
release {
does not display the LOG/* * * */confused
/* * * */

/minifyEnabled false Zipalign optimization * * * */
zipAlignEnabled true
Remove useless resource files/* * * */
shrinkResources true
proguardFiles getDefaultProguardFile (‘ proguard – android. TXT), ‘proguard – rules. Pro’
The debug {

minifyEnabled false shrinkResources false
proguardFiles getDefaultProguardFile (‘ proguard – android. TXT), ‘proguard – rules. Pro’


ShrinkResources = false Release ShrinkResources = false Interested can go to the Internet to check the reason.

The Android packaging problem is solved.

It’s as simple as that.

Android studio reported an error in the release package: Lint found fatal errors while assembling a release target

Today, I upgraded Android Studio and found that the code can run, but there is an error in the release package. The error is as follows

Lint found fatal errors while assembling a release target.
To proceed, either fix the issues identified by lint, or modify your build script as follows:
android {
    lintOptions {
        checkReleaseBuilds false
        // Or, if you prefer, you can continue to check for errors in release builds,
        // but continue the build even when errors are found:
        abortOnError false

The error provides us with the above two kinds of repair way of version
a: repair
Lint to check out the problem 2: in the build of the module. The gradle add the following code, so you can ignore these problems, the normal packaging

android {
    lintOptions {
        checkReleaseBuilds false
        // Or, if you prefer, you can continue to check for errors in release builds,
        // but continue the build even when errors are found:
        abortOnError false

The second method is convenient, but it’s not recommended to ignore the problem, according to the website

In addition to testing the Android application to make sure it meets its functional requirements, you must also make sure that the code has no structural problems. Disorganized code affects the reliability and efficiency of an Android application and makes it harder to maintain the code.

Lint check problems is to prevent the above problems, so the way we use the following method to solve this problem
in the error above only hint Lint has a problem But didn’t tell me about any problem. Can use the android studio to see these errors

in the menu bar

can complete inspection can also specify folder check, click OK to wait for a while can see the test result, and then the error of the test results to solve can normal packing up

Reference links

Android studio introduces code error, but it can run normally

I just encountered this problem because the computer monitor was black, so I directly shut down and restarted the project. After booting up, the AndroidStudio project could run normally, but many clearly existing classes were reported to introduce errors, causing various methods and classes to draw red lines, although they could run normally, but this has affected the normal development.
After searching on the Internet, I found several solutions and tried to find the most effective one:
1. Close AndroidStudio
: : Users\WIN10\.AndroidStudio3.4

Android studio push project to GitHub

Introduction :Android Studio itself supports Github. So it’s easy to push direct code onto Github.

Prepare _ configuration account
Import the Git
Settings -> Version Control -> Set Git directory

Set up Github
After setting, click Test to Test.

Prepare 2_ create project
Create the As project

Create Github’s repository

Add Git management to the As project

Add the address of the Push
1. Right mouse button in the testProject created = “gitBash

Add Git management to files in your Git directory

Then commit

Then push

If all goes well, you can see that the document was submitted successfully.

Android studio disable install run

Recently, I have been trying to access Tencent’s hot fix solution -Tinker in the project
After clone the sample on Github, I would like to run it on the virtual machine. The error is as follows:

Tinker does not support instant run mode, please trigger build by assembleDebug or disable instant run in 'File->Settings...'.

So go ahead and disable install Run,
Version information:

Android Studio 3.2
Build #AI-181.5540.7.32.5014246, built on September 18, 2018
JRE: 1.8.0_152-release-1136-b06 x86_64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
macOS 10.13.6

The menu bar – & gt; Android Studio -> The Preferences… -> Then it is shown as follows:

And then uncheck the red box,
apply -> ok

Android studio “sync project with gradle files” button disappears

In the process of using Android studio today, I suddenly found a project error. The sync project button appeared and disappeared. My confusion was over.

1.Sync project with Gradle Files button disappears, app mark Red Cross

2. There is nothing in android project area, have I deleted modules?