Tag Archives: android-studio

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

NDK Version Clang++: error: unknown argument: ‘-static-openmp‘

Cmakelists.txt file compiles ncnn and CPP and runs normally on the other two Ubuntu machines.

Similarly, the source code is configured, the project is loaded, and the gradle initialization is correct, but there is an error in compiling APK.

clang++: error: unknown argument: ‘-static-openmp’

After searching for a long time, I can’t see the wrong configuration. I doubt the gradle version. The problem remains after the upgrade; Upgrade the as version, and the problem still occurs.

Open settings, SDK configuration, check SDK tools, and reinstall SDK. The latest SDK 23.0 is installed at once. The error disappears, but there is still a problem with the compilation. It is reduced to SDK 20.0, and the error occurs again.

High or low, choose ndk21.3 and cmake3.10.2. Finally, the compilation is normal and the debugging is passed.

Gradle:Using flatDir should be avoided because it doesn‘t support any meta-data formats.

app.gradle

Code snippet 1:

repositories {
    flatDir {
        dirs 'libs'
    }
}

Code snippet 2:

dependencies {
    classpath "com.android.tools.build:gradle:4.2.2"
}

After gradle is upgraded to 4.2.2, the following prompt message will appear during compilation. Delete & lt; Code snippet 1 & gt; The problem can be solved

Using flatDir should be avoided because it doesn’t support any meta-data formats.
Affected Modules: APP

Use the LIBS directory if necessary

        Add the following code to the project module.gradle

android {
    
    ...

    sourceSets {
        main {
            jniLibs.srcDirs = ['libs']
        }
    }
}

Problem solving.

[Solved] Manifest merger failed: Apps targeting Android 12 and higher are required to specify an explicit

Android Studio run app error:

Manifest merger failed : Apps targeting Android 12 and higher are required to specify an explicit value for `android:exported` when the corresponding component has an intent filter defined. See https://developer.android.com/guide/topics/manifest/activity-element#exported for details.

Environment used: Android studio 4.2.2, Pixel 2 API 29
Solution reference.
Add android:exported to activity in AndroidManifest.xml file, e.g:

<activity android:name=".MainActivity" android:exported="true">

Android studio Error:Execution failed for task ‘: app:transformResourcesWithMergeJavaResForDebug ‘

Android studio error Error:Execution failed for task

Recently, when doing the face recognition check-in system based on Android platform, after importing the third party’s lib package, Android studio reported the following error:

Error:Execution failed for task ‘: app:transformResourcesWithMergeJavaResForDebug ’.
com.android.build . api.transform.TransformException : com.android.builder . packaging.DuplicateFileException : Duplicate files copied in APK META-INF/LICENSE
File1: E:\Workspaces\Swface\app\libs\httpcore-4.4.4.jar
File2: E:\Workspaces\Swface\app\libs\httpclient-4.5.2.jar

After consulting the data, it is found that there are duplicate contents loaded in the meta-inf directory of the jar package. Open the corresponding jar package
sure enough, both of the two jar packages have license, and further Click to find that the contents are exactly the same. However, it seems that the next three files are also duplicate (only there is no clear prompt in the error report), so we can solve them all at once
all Now that we know that it is caused by repeatedly loading files, the solution is to remove the repeatedly loaded files during compilation. The specific operations are as follows:

    1. Open app\ build.gradle File
    1. 2. Modify the configuration as follows:
buildTypes {
          ...... (omit part of the code)
          // Add the following code here
          packagingOptions {
            exclude 'META-INF/DEPENDENCIES'
            exclude 'META-INF/NOTICE'
            exclude 'META-INF/LICENSE'
            exclude 'META-INF/LICENSE.txt'
            exclude 'META-INF/NOTICE.txt'
            exclude 'META-INF/ASL2.0'
            exclude 'META-INF/notice.txt'
        }
 }       
``

3. Rebuild project

A link to the original text is attached

http://stackoverflow.com/questions/34031395/errorexecution-failed-for-task-apptransformresourceswithmergejavaresfordebug

Failed to resolve: failed to resolve

Failed to resolve: failed to resolve*


Background: some time ago, I did a PDF reading function, but when I introduced the remote warehouse dependency package, Android studio always reported errors. Failed to resolve: * well, I don’t need to say much nonsense. I’ll post the process of my solution for the reference of workers.


Premise: delete gradle.properties Then file – & gt; setting – & gt; proxy (search) – & gt; noproxy.
1.
2. Add the address of Alibaba cloud Maven warehouse in Android studio. As shown in the following figure:

3.

Change API level Android studio

Changing API Level Android Studio
I want to change the minimum SDK version in Android Studio from API 12 to API14. I have tried changing it in the manifest file, ie, I want to change the minimum SDK version in Android Studio from API 12 to API14. I tried to make the change in the manifest file, which is

<uses-sdk
    android:minSdkVersion="14"
    android:targetSdkVersion="18" />

and rebuilding the project, but I still get the Android Studio IDE throwing up some errors. and rebuild projects, but I still get the Android Studio IDE throw out some mistakes. I presume I have to set the min SDK in ‘project properties’ or something similar so the IDE recognizes the change, But I can’t find where this is done in Android Studio. I think I have to set the min SDK in project properties or something similar so that the IDE can recognize changes, but I can’t find anything done in Android Studio.


# 1/f,
Reference: https://stackoom.com/question/1JfkP/ change the Android API level – Studio


# 2 floor
For me what worked was: (right click)project-> android tools-> Clear lint markers. , for me, markers that have worked are :(right click) markers -> The android tools – & gt; Remove lint marks. Although for some reason the Manifest reverted to the old (lower) minimum API level, But after I changed it back to the new (higher) API level there was no red error underline and the project now USES the new minimum API level. although for some reason the list has been restored to the old (lower) minimum API level, But after I changed it back to the new (higher) API level, there was no red error underscore, and the project now USES the new lowest API level.
Edit: Sorry, I see you were using Android Studio, not Eclipse. Edit: Sorry, I see you are using Android Studio, not Eclipse. But I guess there is a similar ‘clear lint markers’ in Studio somewhere , which I think might be able to solve the problem.


The # 3 floor
As well as updating the manifest, update the module’s build.gradle file too (it’s listed in the project pane just below the manifest – if there’s no minSdkVersion key in it, you’re looking at the wrong one, Gradle build. Gradle file for the module (list this file in the project pane at the bottom of the list – if there is no minSdkVersion key in it, then you have entered the wrong key because there are several). A rebuild and things should be fine… rebuild, everything should be fine…


# 4 floor
When you want to update your minSdkVersion in an existent project… when you want to update your minSdkVersion in an existing project…

    Update build. Gradle (Module: app)-make sure is the one under gradle 4 build and it is NOT build. Gradle (Project: yourproject) Update build. Gradle (Module: app) App) - make sure it's the one under Gradle Script, not build. Gradle (Project: yourproject).

An example of build.gradle: build.gradle :

apply plugin: 'com.android.application'

android {
    compileSdkVersion 28
    buildToolsVersion "28.0.2"

    defaultConfig {
        applicationId "com.stackoverflow.answer"
        minSdkVersion 21
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}

dependencies {
    androidTestCompile 'junit:junit:4.12'
    compile fileTree(dir: 'libs', include: ['*.jar'])
}
    Sync gradle button (refresh all gradle projects also works) synchronous gradle button (refresh all gradle projects can also work)

For beginners in Android Studio "Sync gradle button" is located in Tools -> Android -> Sync Project with Gradle Files "Rebuild project" Build -> Rebuild Project for beginners in Android Studio, the "sync gradle button" is located in the tool -> Android-> Use Gradle file to synchronize the project "Rebuild Project" build-& gt; Rebuild Project

    Rebuild project Rebuild project

After updating the build.gradle 's minSdkVersion , You have to click on the button to sync gradle file (" sync Project with gradle files"). update build. After gradle minSdkVersion, you must click on the button gradle sync file (' sync Project with cradle files'). That will clear the marker. this will clear the marker.
Updating manifest.xml, for eg deleting any references to SDK levels in the manifest file, is NOT necessary anymore in Android Studio. ; Updating manifest.xml is NOT necessary. For example, remove any references to the SDK level in the manifest file.


The # 5 floor
For android studio users: For android studio users:

    right click the App directory right-click App directory choose the "module setting" option select "module Settings "option change the ADK Platform as what you need0 1 change the ADK Platform 2 3 click Apply click Apply

The gradle will rebuild The project automatically. gradle will automatically rebuild The project.


# 6 building
According to this answer , you just don't include minsdkversion in the manifest.xml, And the build system will use the values from the build.gradle file and put the information into the final apk. according to this answer, you only need to include minsdkversion in the manifest.xml, the build system will use the values in the build.gradle file and put the information into the final apk.
Because the build system needs this information anyway, this makes sense. Because the build system still needs this information, so this makes sense. You should not need to define this values two times. You do not need to define this values twice.
You just have to sync the project after changing the build.gradle file, But Android Studio 0.5.2 display a yellow status bar on top of the build. Gradle editor window to help you you only need to synchronize the project after changing the build. Gradle file, But Android Studio 0.5.2 displays the yellow status bar at the top of the build.gradle editor window to help you
Also note there at least two build. Gradle files: one master and one for the app/module. Also note that there are at least two build. Gradle files: one main file and one file for the application /module. The one to change is in The app/module, it already includes a property minSdkVersion in a newly generated project. to change is in The app/module, It has already included the attribute minSdkVersion in the newly generated project.

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


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