I am trying to run my application on either an emulator or my device. When I click the "run" button at the top of Android Studio, the app is not running but simply listing the message below:
/Library/Java/JavaVirtualMachines/jdk1.8.0_102.jdk/Contents/Home/bin/java "-Dgradle.home=/Applications/Android Studio.app/Contents/gradle/gradle-2.14.1" -Dtools.jar=/Library/Java/JavaVirtualMachines/jdk1.8.0_102.jdk/Contents/Home/lib/tools.jar -Didea.launcher.port=7533 "-Didea.launcher.bin.path=/Applications/Android Studio.app/Contents/bin" -Dfile.encoding=UTF-8 -classpath "/Applications/Android Studio.app/Contents/gradle/gradle-2.14.1/lib/groovy-all-2.4.4.jar:/Applications/Android Studio.app/Contents/gradle/gradle-2.14.1/lib/ant-1.9.6.jar:/Applications/Android Studio.app/Contents/gradle/gradle-2.14.1/lib/ant-launcher-1.9.6.jar:/Applications/Android Studio.app/Contents/gradle/gradle-2.14.1/lib/gradle-base-services-2.14.1.jar:/Applications/Android Studio.app/Contents/gradle/gradle-2.14.1/lib/gradle-base-services-groovy-2.14.1.jar:/Applications/Android Studio.app/Contents/gradle/gradle-2.14.1/lib/gradle-cli-2.14.1.jar:/Applications/Android Studio.app/Contents/gradle/gradle-2.14.1/lib/gradle-core-2.14.1.jar:/Applications/Android Studio.app/Contents/gradle/gradle-2.14.1/lib/gradle-docs-2.14.1.jar:/Applications/Android Studio.app/Contents/gradle/gradle-2.14.1/lib/gradle-installation-beacon-2.14.1.jar:/Applications/Android Studio.app/Contents/gradle/gradle-2.14.1/lib/gradle-jvm-services-2.14.1.jar:/Applications/Android Studio.app/Contents/gradle/gradle-2.14.1/lib/gradle-launcher-2.14.1.jar:/Applications/Android Studio.app/Contents/gradle/gradle-2.14.1/lib/gradle-logging-2.14.1.jar:/Applications/Android Studio.app/Contents/gradle/gradle-2.14.1/lib/gradle-messaging-2.14.1.jar:/Applications/Android Studio.app/Contents/gradle/gradle-2.14.1/lib/gradle-model-core-2.14.1.jar:/Applications/Android Studio.app/Contents/gradle/gradle-2.14.1/lib/gradle-model-groovy-2.14.1.jar:/Applications/Android Studio.app/Contents/gradle/gradle-2.14.1/lib/gradle-native-2.14.1.jar:/Applications/Android Studio.app/Contents/gradle/gradle-2.14.1/lib/gradle-open-api-2.14.1.jar:/Applications/Android Studio.app/Contents/gradle/gradle-2.14.1/lib/gradle-process-services-2.14.1.jar:/Applications/Android Studio.app/Contents/gradle/gradle-2.14.1/lib/gradle-resources-2.14.1.jar:/Applications/Android Studio.app/Contents/gradle/gradle-2.14.1/lib/gradle-tooling-api-2.14.1.jar:/Applications/Android Studio.app/Contents/gradle/gradle-2.14.1/lib/gradle-ui-2.14.1.jar:/Applications/Android Studio.app/Contents/gradle/gradle-2.14.1/lib/gradle-wrapper-2.14.1.jar:/Applications/Android Studio.app/Contents/gradle/gradle-2.14.1/lib/plugins/gradle-announce-2.14.1.jar:/Applications/Android Studio.app/Contents/gradle/gradle-2.14.1/lib/plugins/gradle-antlr-2.14.1.jar:/Applications/Android Studio.app/Contents/gradle/gradle-2.14.1/lib/plugins/gradle-build-comparison-2.14.1.jar:/Applications/Android Studio.app/Contents/gradle/gradle-2.14.1/lib/plugins/gradle-build-init-2.14.1.jar:/Applications/Android Studio.app/Contents/gradle/gradle-2.14.1/lib/plugins/gradle-code-quality-2.14.1.jar:/Applications/Android Studio.app/Contents/gradle/gradle-2.14.1/lib/plugins/gradle-dependency-management-2.14.1.jar:/Applications/Android Studio.app/Contents/gradle/gradle-2.14.1/lib/plugins/gradle-diagnostics-2.14.1.jar:/Applications/Android Studio.app/Contents/gradle/gradle-2.14.1/lib/plugins/gradle-ear-2.14.1.jar:/Applications/Android Studio.app/Contents/gradle/gradle-2.14.1/lib/plugins/gradle-ide-2.14.1.jar:/Applications/Android Studio.app/Contents/gradle/gradle-2.14.1/lib/plugins/gradle-ide-native-2.14.1.jar:/Applications/Android Studio.app/Contents/gradle/gradle-2.14.1/lib/plugins/gradle-ide-play-2.14.1.jar:/Applications/Android Studio.app/Contents/gradle/gradle-2.14.1/lib/plugins/gradle-ivy-2.14.1.jar:/Applications/Android Studio.app/Contents/gradle/gradle-2.14.1/lib/plugins/gradle-jacoco-2.14.1.jar:/Applications/Android Studio.app/Contents/gradle/gradle-2.14.1/lib/plugins/gradle-javascript-2.14.1.jar:/Applications/Android Studio.app/Contents/gradle/gradle-2.14.1/lib/plugins/gradle-jetty-2.14.1.jar:/Applications/Android Studio.app/Contents/gradle/gradle-2.14.1/lib/plugins/gradle-language-groovy-2.14.1.jar:/Applications/Android Studio.app/Contents/gradle/gradle-2.14.1/lib/plugins/gradle-language-java-2.14.1.jar:/Applications/Android Studio.app/Contents/gradle/gradle-2.14.1/lib/plugins/gradle-language-jvm-2.14.1.jar:/Applications/Android Studio.app/Contents/gradle/gradle-2.14.1/lib/plugins/gradle-language-native-2.14.1.jar:/Applications/Android Studio.app/Contents/gradle/gradle-2.14.1/lib/plugins/gradle-language-scala-2.14.1.jar:/Applications/Android Studio.app/Contents/gradle/gradle-2.14.1/lib/plugins/gradle-maven-2.14.1.jar:/Applications/Android Studio.app/Contents/gradle/gradle-2.14.1/lib/plugins/gradle-osgi-2.14.1.jar:/Applications/Android Studio.app/Contents/gradle/gradle-2.14.1/lib/plugins/gradle-platform-base-2.14.1.jar:/Applications/Android Studio.app/Contents/gradle/gradle-2.14.1/lib/plugins/gradle-platform-jvm-2.14.1.jar:/Applications/Android Studio.app/Contents/gradle/gradle-2.14.1/lib/plugins/gradle-platform-native-2.14.1.jar:/Applications/Android Studio.app/Contents/gradle/gradle-2.14.1/lib/plugins/gradle-platform-play-2.14.1.jar:/Applications/Android Studio.app/Contents/gradle/gradle-2.14.1/lib/plugins/gradle-plugin-development-2.14.1.jar:/Applications/Android Studio.app/Contents/gradle/gradle-2.14.1/lib/plugins/gradle-plugin-use-2.14.1.jar:/Applications/Android Studio.app/Contents/gradle/gradle-2.14.1/lib/plugins/gradle-plugins-2.14.1.jar:/Applications/Android Studio.app/Contents/gradle/gradle-2.14.1/lib/plugins/gradle-publish-2.14.1.jar:/Applications/Android Studio.app/Contents/gradle/gradle-2.14.1/lib/plugins/gradle-reporting-2.14.1.jar:/Applications/Android Studio.app/Contents/gradle/gradle-2.14.1/lib/plugins/gradle-resources-http-2.14.1.jar:/Applications/Android Studio.app/Contents/gradle/gradle-2.14.1/lib/plugins/gradle-resources-s3-2.14.1.jar:/Applications/Android Studio.app/Contents/gradle/gradle-2.14.1/lib/plugins/gradle-resources-sftp-2.14.1.jar:/Applications/Android Studio.app/Contents/gradle/gradle-2.14.1/lib/plugins/gradle-scala-2.14.1.jar:/Applications/Android Studio.app/Contents/gradle/gradle-2.14.1/lib/plugins/gradle-signing-2.14.1.jar:/Applications/Android Studio.app/Contents/gradle/gradle-2.14.1/lib/plugins/gradle-sonar-2.14.1.jar:/Applications/Android Studio.app/Contents/gradle/gradle-2.14.1/lib/plugins/gradle-test-kit-2.14.1.jar:/Applications/Android Studio.app/Contents/gradle/gradle-2.14.1/lib/plugins/gradle-testing-base-2.14.1.jar:/Applications/Android Studio.app/Contents/gradle/gradle-2.14.1/lib/plugins/gradle-testing-jvm-2.14.1.jar:/Applications/Android Studio.app/Contents/gradle/gradle-2.14.1/lib/plugins/gradle-testing-native-2.14.1.jar:/Applications/Android Studio.app/Contents/gradle/gradle-2.14.1/lib/plugins/gradle-tooling-api-builders-2.14.1.jar:/Applications/Android Studio.app/Contents/gradle/gradle-2.14.1/lib/plugins/ivy-2.2.0.jar:/Applications/Android Studio.app/Contents/lib/idea_rt.jar" com.intellij.rt.execution.application.AppMain org.gradle.launcher.GradleMain --build-file /Users/troychuinard/Code/FanPolls/app/build.gradle
Incremental java compilation is an incubating feature.
:app:help
Welcome to Gradle 2.14.1.
To run a build, run gradle <task> ...
To see a list of available tasks, run gradle tasks
To see a list of command-line options, run gradle --help
To see more detail about a task, run gradle help --task <task>
BUILD SUCCESSFUL
Total time: 8.841 secs
This build could be faster, please consider using the Gradle Daemon: https://docs.gradle.org/2.14.1/userguide/gradle_daemon.html
Process finished with exit code 0
The prompt is never appearing that asks me to select a deployment target. What is the setting in Android Studio to enable?
To enable the Deployment Target Dialog go to Run -> Edit Configuration -> Android App (app) -> Target: Open Select Deployment Target Dialog
Besides that you also have to enable developer mode on your device and have the drivers installed via the SDK manager or the manufacturer.
To check if your device is recognized you can use adb devices and it should be listed.
The adb is located under the platform-tools e.g.
C:\Users\You\AppData\Local\Android\sdk\platform-tools
I found that the android build tools version 25.0.0 resolves this issue, I was previously using 25.0.1 and it was not loading the device chooser:
android {
compileSdkVersion 24
buildToolsVersion '25.0.0'
}
Anyone able to run with the latest build tools?
Related
There were lots of Mapping new... logs, so i deleted a big chunk, because I exceeded the available characters
(I'm not sure if this is the problem) It says it's something related to the licences, but I already accepted them all, as far as I know.
In the images I show you what I've installed throught Android Studio, everything seems fine.
npx react-native run-android
info Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" flag.
Jetifier found 863 file(s) to forward-jetify. Using 2 workers...
info JS server already running.
/bin/sh: 1: /home/u/platform-tools/adb: not found
info Launching emulator...
error Failed to launch emulator. Reason: No emulators found as an output of `emulator -list-avds`.
warn Please launch an emulator manually or connect a device. Otherwise app may fail to launch.
info Installing the app...
Mapping new ns http://schemas.android.com/sdk/android/repo/sys-img2/02 to old ns http://schemas.android.com/sdk/android/repo/sys-img2/01
Observed package id 'system-images;android-29;google_apis;x86' in inconsistent location '/home/u/Android/Sdk/system-images/android-29/google_apis/x86' (Expected '/home/u/system-images/android-29/google_apis/x86')
Mapping new ns http://schemas.android.com/repository/android/common/02 to old ns http://schemas.android.com/repository/android/common/01
Mapping new ns http://schemas.android.com/repository/android/generic/02 to old ns http://schemas.android.com/repository/android/generic/01
Mapping new ns http://schemas.android.com/sdk/android/repo/addon2/02 to old ns http://schemas.android.com/sdk/android/repo/addon2/01
Mapping new ns http://schemas.android.com/sdk/android/repo/addon2/03 to old ns http://schemas.android.com/sdk/android/repo/addon2/01
Mapping new ns http://schemas.android.com/sdk/android/repo/repository2/02 to old ns http://schemas.android.com/sdk/android/repo/repository2/01
Mapping new ns http://schemas.android.com/sdk/android/repo/repository2/03 to old ns http://schemas.android.com/sdk/android/repo/repository2/01
Mapping new ns http://schemas.android.com/sdk/android/repo/sys-img2/03 to old ns http://schemas.android.com/sdk/android/repo/sys-img2/01
Mapping new ns http://schemas.android.com/sdk/android/repo/sys-img2/02 to old ns http://schemas.android.com/sdk/android/repo/sys-img2/01
Observed package id 'tools' in inconsistent location '/home/u/Android/Sdk/tools' (Expected '/home/u/tools')
Checking the license for package Android SDK Build-Tools 30.0.2 in /home/u/licenses
Warning: License for package Android SDK Build-Tools 30.0.2 not accepted.
Checking the license for package Android SDK Platform 30 in /home/u/licenses
Warning: License for package Android SDK Platform 30 not accepted.
FAILURE: Build failed with an exception.
* What went wrong:
Could not determine the dependencies of task ':app:compileDebugJavaWithJavac'.
> Failed to install the following Android SDK packages as some licences have not been accepted.
build-tools;30.0.2 Android SDK Build-Tools 30.0.2
platforms;android-30 Android SDK Platform 30
To build this project, accept the SDK license agreements and install the missing components using the Android Studio SDK Manager.
Alternatively, to transfer the license agreements from one workstation to another, see http://d.android.com/r/studio-ui/export-licenses.html
Using Android SDK: /home/u
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 1m 38s
error Failed to install the app. Please accept all necessary Android SDK licenses using Android SDK Manager: "$ANDROID_HOME/tools/bin/sdkmanager --licenses".
Error: Command failed: ./gradlew app:installDebug -PreactNativeDevServerPort=8081
FAILURE: Build failed with an exception.
* What went wrong:
Could not determine the dependencies of task ':app:compileDebugJavaWithJavac'.
> Failed to install the following Android SDK packages as some licences have not been accepted.
build-tools;30.0.2 Android SDK Build-Tools 30.0.2
platforms;android-30 Android SDK Platform 30
To build this project, accept the SDK license agreements and install the missing components using the Android Studio SDK Manager.
Alternatively, to transfer the license agreements from one workstation to another, see http://d.android.com/r/studio-ui/export-licenses.html
Using Android SDK: /home/u
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 1m 38s
at makeError (/home/u/Desktop/workdir/Math_App/mathapp/node_modules/#react-native-community/cli-platform-android/node_modules/execa/index.js:174:9)
at /home/u/Desktop/workdir/Math_App/mathapp/node_modules/#react-native-community/cli-platform-android/node_modules/execa/index.js:278:16
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async runOnAllDevices (/home/u/Desktop/workdir/Math_App/mathapp/node_modules/#react-native-community/cli-platform-android/build/commands/runAndroid/runOnAllDevices.js:109:5)
at async Command.handleAction (/home/u/Desktop/workdir/Math_App/mathapp/node_modules/#react-native-community/cli/build/index.js:192:9)
info Run CLI with --verbose flag for more details.
It basically indicates it's missing build-tools;30.0.2 Android SDK Build-Tools 30.0.2 platforms;android-30 Android SDK Platform 30
Install them throught Android-Studio, and everything should work.
Addionaty to that, I'd another problem (probably unrelated to the one on top, but I'll still add it here)
So, now if I try again npx react-native run-android the following error pops us
[adb]: Cannot run program "/home/u/platform-tools/adb": error=2, No such file or directory
platform-tools lives inside ~/Android/Sdk, not inside ~/ .
Basically it means that the path is wrong. Fix for that is here
While developing an app I came into following error. I tried downgrading the java version from 11 to 8, but that wasn't helpful.
FAILURE: Build failed with an exception.
* What went wrong:
Could not create service of type ScriptPluginFactory using BuildScopeServices.createScriptPluginFactory().
> Could not create service of type PluginResolutionStrategyInternal using BuildScopeServices.createPluginResolutionStrategy().
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 15s
Could not install the app on the device, read the error above for details.
Make sure you have an Android emulator running or a device connected and have
set up your Android development environment:
https://facebook.github.io/react-native/docs/getting-started.html
Command failed: gradlew.bat installDebug
Error: Command failed: gradlew.bat installDebug
at checkExecSyncError (child_process.js:616:11)
at Object.execFileSync (child_process.js:634:13)
at runOnAllDevices (C:\Users\samie\Documents\React Native\auth\node_modules\react-native\local-cli\runAndroid\runAndroid.js:299:19)
at buildAndRun (C:\Users\samie\Documents\React Native\auth\node_modules\react-native\local-cli\runAndroid\runAndroid.js:135:12)
at isPackagerRunning.then.result (C:\Users\samie\Documents\React Native\auth\node_modules\react-native\local-cli\runAndroid\runAndroid.js:65:12)
at process._tickCallback (internal/process/next_tick.js:68:7)
How I solved this problem:
First, make sure that I have %java_home% variable set and also %path% has the java sdk included.
How to setup Java environment variables
Second, Go to your android folder and run this command:
C:\Projects\myproject\android>gradlew.bat app:installDebug.
Unzipping
C:\Users\codeb.gradle\wrapper\dists\gradle-4.10.2-all\9fahxiiecdb76a5g3aw9oi8rv\gradle-4.10.2-all.zip
to
C:\Users\codeb.gradle\wrapper\dists\gradle-4.10.2-all\9fahxiiecdb76a5g3aw9oi8rv
Exception in thread "main" java.util.zip.ZipException: error in
opening zip file
at java.util.zip.ZipFile.open(Native Method)
at java.util.zip.ZipFile.(ZipFile.java:225)
at java.util.zip.ZipFile.(ZipFile.java:155)
at java.util.zip.ZipFile.(ZipFile.java:169)
at org.gradle.wrapper.Install.unzip(Install.java:215)
at org.gradle.wrapper.Install.access$600(Install.java:27)
at org.gradle.wrapper.Install$1.call(Install.java:75)
at org.gradle.wrapper.Install$1.call(Install.java:48)
at org.gradle.wrapper.ExclusiveFileAccessManager.access(ExclusiveFileAccessManager.java:69)
at org.gradle.wrapper.Install.createDist(Install.java:48)
at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:107)
at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:61)
As you can see that my gradle download is corrupt. All you have to do is delete this folder and rerun the command.
C:\Projects\myproject\android>gradlew.bat app:installDebug
Downloading
https://services.gradle.org/distributions/gradle-4.10.2-all.zip
...............................................................................................................
Unzipping
C:\Users\codeb.gradle\wrapper\dists\gradle-4.10.2-all\9fahxiiecdb76a5g3aw9oi8rv\gradle-4.10.2-all.zip
to
C:\Users\codeb.gradle\wrapper\dists\gradle-4.10.2-all\9fahxiiecdb76a5g3aw9oi8rv
Welcome to Gradle 4.10.2!
Here are the highlights of this release:
- Incremental Java compilation by default
- Periodic Gradle caches cleanup
- Gradle Kotlin DSL 1.0-RC6
- Nested included builds
- SNAPSHOT plugin versions in the plugins {} block
For more details see https://docs.gradle.org/4.10.2/release-notes.html
Now, you can go back to your react native project and run
react-native run-android
info JS server already running. info Building and installing the app
on the device (cd android && gradlew.bat app:installDebug)...
Task :app:installDebug 01:03:18 V/ddms: execute: running am get-config 01:03:18 V/ddms: execute 'am get-config' on 'emulator-5554'
: EOF hit. Read: -1 01:03:18 V/ddms: execute: returning Installing APK
'app-debug.apk' on 'Pixel_2_API_28(AVD) - 9' for app:debug 01:03:18
D/app-debug.apk: Uploading app-debug.apk onto device 'emulator-5554'
01:03:18 D/Device: Uploading file onto device 'emulator-5554' 01:03:18
D/ddms: Reading file permision of
C:\Projects\xx\android\app\build\outputs\apk\debug\app-debug.apk
as: rwx------ 01:03:18 V/ddms: execute: running pm install -r -t
"/data/local/tmp/app-debug.apk" 01:03:19 V/ddms: execute 'pm install
-r -t "/data/local/tmp/app-debug.apk"' on 'emulator-5554' : EOF hit. Read: -1 01:03:19 V/ddms: execute: returning 01:03:19 V/ddms: execute:
running rm "/data/local/tmp/app-debug.apk" 01:03:19 V/ddms: execute
'rm "/data/local/tmp/app-debug.apk"' on 'emulator-5554' : EOF hit.
Read: -1 01:03:19 V/ddms: execute: returning Installed on 1 device.
BUILD SUCCESSFUL in 9s 27 actionable tasks: 1 executed, 26 up-to-date
info Running
C:\Users\codeb\AppData\Local\Android\Sdk/platform-tools/adb -s
emulator-5554 reverse tcp:8081 tcp:8081 info Starting the app on
emulator-5554
(C:\Users\codeb\AppData\Local\Android\Sdk/platform-tools/adb -s
emulator-5554 shell am start -n
com.myproject/com.myproject.MainActivity)... Starting:
Intent { cmp=com.myproject/.MainActivity }
Try running this command inside your project file
react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res
after that
cd (path to project/android folder) && gradlew clean && cd .. && react-native run-android
always gradlew clean before run react-native-run-android
the above command basically cleans up the gradle and previous builds.
for ENOENT Error
Check if $ yarn start works. The metro bundler wasn't able to run on port 8081 for me and I needed to run $ killall node
EDIT:
Also update the gradle-wrapper.properties
add
distributionUrl=https\://services.gradle.org/distributions/gradle-5.2.1-all.zip
remove following code from build.gradle:
task wrapper(type: Wrapper) {
gradleVersion = '5.2.1'
distributionUrl = distributionUrl.replace("bin", "all")
}
after that
cd (path to project/android folder) && gradlew clean && cd .. && react-native run-android
always gradlew clean before run react-native-run-android the above command basically cleans up the gradle and previous builds.
You're good to go!
Just run sudo react-native run-android and it will build and install ./gradlew app:installDebug inside android directory for you.
I had this issue too and I was able to fix it by creating a new project in react-native 0.57.3 using the command:
react-native init --version="0.57.3" MyNewApp
You have to update the gradle-wrapper.properties file to use the newest version of gradle:
distributionUrl=https\://services.gradle.org/distributions/gradle-5.2.1-all.zip
And remove this block from build.gradle file:
task wrapper(type: Wrapper) {
gradleVersion = '5.2.1'
distributionUrl = distributionUrl.replace("bin", "all")
}
Then run a gradlew clean on the android folder and everything should work.
I had this issue too and I was able to fix it by run ./gradlew app:installDebug in android folder .
In my case, I uninstalled my java jdk17 and installed java jdk11. It worked for me few seconds ago. Really happy :)))
I had this issue myself, it eventually went away after I uninstalled and re-installed android studio and gradle, but a few other things you could try first
1: Setting GRADLE_USER_HOME in environment variables (if on windows)
2: Downgrade to react-native 0.57.0
3: Make sure you have the correct permissions to run the command and access files
4: Make sure your gradle files are synced correctly, and that location of gradle and the android skd are correct within project structure offline mode
5: Check gradle for updates
(Assuming you are using android studio)
Good luck
The problem is on file:
nameyourapp/android/local.properties
you have to substitute with the correct path: /Users/nameUser/AppData/Local/Android/sdk
I have the same error I just uninstall the JDK old version and install the latest version from https://www.oracle.com/java/technologies/javase-downloads.html and now it's working.
Open your settings.grandler file in the android folder
Change the \ to /
Save the file
Run the command react-native run-android
I am attempting to setup Travis CI so that it runs instrumentation tests on an emulator running API 25. Travis runs the tests to completion on API 4/10/19, but fails to startup the emulator for API 25, with the following message:
$ echo no | android create avd --force -n test -t $ANDROID_TARGET --abi $ANDROID_ABI
Valid ABIs: no ABIs.
Error: Invalid --abi armeabi-v7a for the selected target.
The output of android list targets shows that the API 19 emulator has a Tag/ABI, whereas the API 25 emulator does not:
id: 7 or "android-19"
Name: Android 4.4.2
Type: Platform
API level: 19
Revision: 4
Skins: HVGA, QVGA, WQVGA400, WQVGA432, WSVGA, WVGA800 (default), WVGA854, WXGA720, WXGA800, WXGA800-7in
Tag/ABIs : default/armeabi-v7a
id: 11 or "android-25"
Name: Android 7.1.1
Type: Platform
API level: 25
Revision: 3
Skins: HVGA, QVGA, WQVGA400, WQVGA432, WSVGA, WVGA800 (default), WVGA854, WXGA720, WXGA800, WXGA800-7in
Tag/ABIs : no ABIs.
How can I fix this so that the API 25 emulator launches and runs the tests?
The full .travis.yml file is as follows:
language: android
android:
components:
- tools
- platform-tools
- tools # appears twice as per Travis docs
- build-tools-23.0.1
- build-tools-25.0.2
- android-4
- android-10
- android-19
- android-23
- android-25
- extra-android-m2repository
- sys-img-armeabi-v7a-android-25
env:
matrix:
- ANDROID_TARGET=android-4 ANDROID_ABI=armeabi
- ANDROID_TARGET=android-10 ANDROID_ABI=armeabi
- ANDROID_TARGET=android-19 ANDROID_ABI=armeabi-v7a
- ANDROID_TARGET=android-25 ANDROID_ABI=armeabi-v7a
before_script:
# Create and start emulator
- android list targets
- jdk_switcher use oraclejdk8
- echo no | android create avd --force -n test -t $ANDROID_TARGET --abi $ANDROID_ABI
- emulator -avd test -no-skin -no-audio -no-window &
- adb wait-for-device
- while [[ `adb shell pm path android` == 'Error'* ]]; do sleep 2; done
- adb shell input keyevent 82 &
script: ./gradlew --info connectedAndroidTest
sudo: false
Note: emulator version 26.1.4+ versions can introduce or fix bugs. If a reproducible ci build is required, the best option is to download the desired sdk-tools version no via android components.
Note: emulator version 26.1.3 is here including interesting fixes. I'm busy to revise my answer now:
Related issue using emulator 26.1.2 here. Relaunch last build like me to use 26.1.3 and pray, green
I am attempting to setup Travis CI so that it runs instrumentation
tests on an emulator running API 25. Travis runs the tests to
completion on API 4/10/19, but fails to startup the emulator for API
25...
How can I fix this so that the API 25 emulator launches and runs the
tests?
Update: I confirmed that ARM ABIs for APIs 23, 25 and 26 are also missing in Android Studio, so:
It's not a Travis-ci issue. I reproduced it locally as shown in the next image.
You can use ARM ABI for API-24. I forked your project and it worked in build #6 (next image).
You can use Google APIs image for API-25 as I explain below using the new sdkmanager: 1
You can use Google APIs image for API-25 using legacy tools if you know the img name: 1,2,3
We need to ask to Google or someone else why the ARM ABIs for these APIs are missing.
Update: A related bug was already reported to Google and discussed here, please, star it:
For some reason it's marked as being only available on windows. I'm
not sure if this is a problem with ADRT itself or the configuration
for this package, but from a quick look it seems like it's probably a
problem with adrt itself.
I'm not sure if the api-25 issue is related but I expect that it will work combining several solutions:
Use system images with google_apis to simplify the build matrix and avoid missing ABIs.
Use the new sdkmanager and avdmanager required by the recent Sdk Tools.
Use the new Trusty images including these tools to simplify the Travis-ci configuration or alternatively use dist: precise as explained here.
See the links below to working samples using a build matrix that includes Api-25 emulator.
I updated the api 23 system image one time on a macbook via Android Studio and appeared a message about the new version was not supported by my computer, so I use the google_apis one.
I offer a possible solution to the issue commented by Ashish Pathak (I'm also ardock) here.
I need to update my response to support the new Travis-ci images that comes with new SDK tools.
The new pre-installed Sdk Tools will simplify the solution and reduce the YAML file in size.
As announced in this blog post by Carmen Andoh and Dominic Jodoin on 19 Jun 2017:
Updates are coming to all Ubuntu Trusty 14.04 images
This new generation of Trusty images is already available in
production and can be used by adding group: edge in your .travis.yml
file:
sudo: required
dist: trusty
group: edge # Add this
And as explained here:
As a bit more information, this new Android image comes with:
Android SDK 25.2.3 build-tools-25.0.2
The new sdkmanager tool - a command line tool that allows you to view,
install, update, and uninstall packages for the Android SDK. Replaces
the previous android tool, see
https://developer.android.com/studio/tools/help/android.html
Also, the new Android image should be retro-compatible. See the full
list of Android SDK components that can be specified in the
.travis.yml file, including build-tools-26.0.0-preview.
But they are not using the new avdmanager, I'll try to fix it this weekend.
Alternatively, you can use the previous images by adding dist: precise.
The lines below are part of my answer on a related question: prior to the images update:
Full working sample using constraint-layout codelab repository for Android API level 22 to 25:
Two more samples using sdkmanager and avdmanager:
Android Maps Utils library - Google
Dexter library - Karumi
References
Official documentation related to Auto-download missing packages with Gradle
The new Emulator options are explained in Start the Emulator from the Command Line
avdmanager explained here replaces android avd since SDK tools version 25.3.0
sdkmanager explained here also enhanced to view and accept all licenses from the command line
For the last few days I've been unable to run cordova run android (or rather, ionic run android) to test my Ionic app on my native device. When I run the command, I get the usual metric ton of output, along with 100% CPU usage from several Java Runtime processes, then the build finally fails with the stated in the title. The console shows this (truncated, as there's a ton of output):
:compileDebugNdk UP-TO-DATE :compileDebugSources
:transformClassesWithDexForDebug 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:484)
at com.android.dx.merge.DexMerger$IdMerger.mergeSorted(DexMerger.java:261)
at com.android.dx.merge.DexMerger.mergeMethodIds(DexMerger.java:473)
at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:161)
at com.android.dx.merge.DexMerger.merge(DexMerger.java:188) FAILED
BUILD FAILED
Total time: 1 mins 40.116 secs
at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:504)
at com.android.dx.command.dexer.Main.runMonoDex(Main.java:334)
at com.android.dx.command.dexer.Main.run(Main.java:277)
at com.android.dx.command.dexer.Main.main(Main.java:245)
at com.android.dx.command.Main.main(Main.java:106)
FAILURE: Build failed with an exception.
What went wrong: Execution failed for task :transformClassesWithDexForDebug.
com.android.build.api.transform.TransformException:
com.android.ide.common.process.ProcessException:
org.gradle.process.internal.ExecException:
Process 'command
'C:\Program Files\Java\jdk1.8.0_73\bin\java.exe'' finished with
non-zero exit value 2
Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Error: Error code 1 for command: cmd with args:
/s,/c,"E:\Documents\GitHub\app.auroras.live\platforms\android\gradlew
cdvBuildDebug -b
E:\Documents\GitHub\app.auroras.live\platforms\android\build.gradle
-PcdvBuildArch=arm -Dorg.gradle.daemon=true -Pandroid.useDeprecatedNdk=true"
I just went and updated any necessary tools and libraries in the Android SDK, then I removed and re-added the Android platform (cordova platform add android), making sure to check that all the relevant platform files were gone, and the project still fails to build.
EDIT: I also ran cordova clean, but that didn't work. It looks like the Google Play Services library is causing my app to hit the 64,000 method limit, but other than manually tweaking my gradle file (which I'm not au fait with yet), I'm not sure how I can shrink that down
EDIT 2: I tried tweaking my build.gradle file to remove the reference to "com.google.android.gms:play-services:+" (which I think is pushing my app above the 65535 method limit) but it just keeps coming back.
I also tried a build-extras.gradle to remove the dependency, but got another error. Ideally I'd like an answer that doesn't require constant re-working every time I want to build my app, but at this stage I'm keen for pretty much anything.
I did recently upgrade cordova, ionic and bower (using npm install -g cordova ionic bower after something went screwy with my %PATH% variable on Windows, but I wouldn't imagine that would break anything.
I'm running Windows 10, x64. java -version reports:
java version "1.8.0_73"
Java(TM) SE Runtime Environment (build 1.8.0_73-b02)
Java HotSpot(TM) 64-Bit Server VM (build 25.73-b02, mixed mode)
Any suggestions?
:transformClassesWithDexForDebug UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexIndexOverflowException: method ID not in [0,
0xffff]: 65536
This message sounds like your project is too large.
You have too many methods. There can only be 65536 methods for dex.
Since the gradle plugin 0.14.0 and the Build Tools 21.1.0 you can use the multidex support.
Just add these lines in the build.gradle:
android {
defaultConfig {
...
// Enabling multidex support.
multiDexEnabled true
}
...
}
dependencies {
compile 'com.android.support:multidex:1.0.0'
}
Also in your Manifest add the MultiDexApplication class from the multidex support library to the application element
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.android.multidex.myapplication">
<application
...
android:name="android.support.multidex.MultiDexApplication">
...
</application>
</manifest>
If you are using a own Application class, change the parent class from Application to MultiDexApplication.
#Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
MultiDex.install(this);
}
For google play service:
Google Play services and DEX method limits
Resource Link:
Configuring Your App for Multidex with Gradle
Optimizing Multidex Development Builds
The routine builds performed as part of the development process with multidex typically take longer and can potentially slow your development process.
In order to mitigate the typically longer build times for multidex output, you should create two variations on your build output using the Android plugin for Gradle productFlavors: a development flavor and a production flavor.
The following build configuration sample demonstrates the how to set up these flavors in a Gradle build file:
android {
productFlavors {
// Define separate dev and prod product flavors.
dev {
// dev utilizes minSDKVersion = 21 to allow the Android gradle plugin
// to pre-dex each module and produce an APK that can be tested on
// Android Lollipop without time consuming dex merging processes.
minSdkVersion 21
}
prod {
// The actual minSdkVersion for the application.
minSdkVersion 14
}
}
...
buildTypes {
release {
runProguard true
proguardFiles getDefaultProguardFile('proguard-android.txt'),
'proguard-rules.pro'
}
}
}
dependencies {
compile 'com.android.support:multidex:1.0.0'
}
Resource Link:
DexIndexOverflowException issue after updating to latest appcompat and support library
Unable to execute dex: method ID not in [0, 0xffff]: 65536
Modifying build.gradle directly is not advisable as the changes will be overwritten after building android platform. Any extensions to build.gradle should be done by adding additional file like 'build-extras.gradle' as suggested in official documentation. As suggested by Grayda, the cleaner solution is to use the plugin which does the job like charm.
Came across one more cordova multiplex plugin which does the job and which is active. You can install the plugin using following command:
cordova plugin add https://github.com/solent/cordova-plugin-multidex
Posting the answer as it may benefit someone out there.
In addition to #SkyWalker's answer, I discovered a Cordova multidex plugin that is a lot "cleaner" (that is, no manual modification to your build.gradle files).
You simply install it with cordova plugin add --save https://github.com/jwall149/cordova-multidex and on next build, multidex will be enabled, which will resolve this issue.
When trying to build my phone gap app for android using
sudo phonegap build android
it fails with this error:
:compileDebugJava
/Users/youssefsami/Library/Mobile Documents/com~apple~CloudDocs/Developer/Mobile Apps/UzuConvert/platforms/android/src/org/apache/cordova/inappbrowser/InAppBrowser.java:120: error: cannot find symbol
|| Config.isUrlWhiteListed(url)) {
^
symbol: method isUrlWhiteListed(String)
location: class Config
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
1 error
FAILED
FAILURE:
Build failed with an exception.
* What went wrong:
Execution failed for task ':compileDebugJava'.
>
Compilation failed; see the compiler error output for details.
* Try:
Run with
--stacktrace option to get the stack trace. Run with
--info or
--debug
option to get more log output.
BUILD FAILED
Total time: 5.607 secs
/Users/youssefsami/Library/Mobile Documents/com~apple~CloudDocs/Developer/Mobile Apps/UzuConvert/platforms/android/cordova/node_modules/q/q.js:126
throw e;
^
Error code 1 for command: /Users/youssefsami/Library/Mobile Documents/com~apple~CloudDocs/Developer/Mobile Apps/UzuConvert/platforms/android/gradlew with args: cdvBuildDebug,-b,/Users/youssefsami/Library/Mobile Documents/com~apple~CloudDocs/Developer/Mobile Apps/UzuConvert/platforms/android/build.gradle,-Dorg.gradle.daemon=true
ERROR building one of the platforms: Error: /Users/youssefsami/Library/Mobile Documents/com~apple~CloudDocs/Developer/Mobile Apps/UzuConvert/platforms/android/cordova/build: Command failed with exit code 1
You may not have the required environment or OS to build this project
Error: /Users/youssefsami/Library/Mobile Documents/com~apple~CloudDocs/Developer/Mobile Apps/UzuConvert/platforms/android/cordova/build: Command failed with exit code 1
at ChildProcess.whenDone (/usr/local/lib/node_modules/phonegap/node_modules/cordova/node_modules/cordova-lib/src/cordova/superspawn.js:131:23)
at ChildProcess.emit (events.js:110:17)
at maybeClose (child_process.js:1015:16)
at Process.ChildProcess._handle.onexit (child_process.js:1087:5)
I tried setting the java_home to the java alias in lib exec but still nothing. Any ideas on what maybe causing the problem?
It's because your InAppBrowser plugin is out date and probably out of sync with a newer version of the Cordova Android platform than when you first installed the plugin. I was getting the same issue with cordova-android#4.0.0 and 0.5.3 of InAppBrowser.
Fix is to first remove plugin
cordova plugin rm org.apache.cordova.inappbrowser
Then add it again (it should reinstall with the latest version the cordova CLI has in my case it grabbed 0.6). You can check the version in the RELEASENOTES.md in the plugins/org.apache.cordova.inappbrowser/ folder.
cordova plugin add org.apache.cordova.inappbrowser
You will need to remove the android platform and re-add it before building again so it doesn't keep the old version of the plugin.
cordova platform rm android
and
cordova platform add android
Now build again and the error should have gone.
EDIT: I just noticed at the top of your question you are using phonegap. Since you tagged with cordova (and thats what I use) I answered with cordova commands, but I'm guessing almost the same process applies with Phonegap.
Same problem with cordova-android#4.0.0
Thank's JDawgg your solution's better than mine, but if someone still have the bug you can use cordova-android#3.6.4 like this :
cordova platform remove android
then
cordova platform add android#3.6.4
you must have android 4.2.2 sdk installed
Finally
sudo phonegap build android
In case someone is using Meteor and came across the same problem, martijnwalraven suggests removing the older version of cordova-plugin-inappbrowser and add the most recent one:
$ meteor remove cordova:cordova-plugin-inappbrowser
$ meteor add cordova:cordova-plugin-inappbrowser#1.0.1
This did the trick for me!