Launching lib/main.dart on Android SDK built for x86 in debug mode...
[!] Gradle does not have execution permission.
You should change the ownership of the project directory to your user, or move the project to a directory with execute permissions.
Gradle task assembleDebug failed with exit code 1
Exited (sigterm)
I got the same error trying to execute flutter run on a mac. Apparently, in your flutter project, there is a file android/gradlew that is expected to be executable (and it wasn't). So in my case, I ran...
chmod a+rx android/gradlew
...afterwards the flutter command worked.
FOR FLUTTER
I have tried mostly everything mentioned here and on my own. The solution, actually, it is a series of solutions and worked for me, I am mentioning them try as you wish.
Make sure no antivirus *firewall is blocking,
gradle.bat, gradlew.bat,
git,
flutter,
android studio
Get the latest Gradle and install it to lower privilege directory, not in Program Files or Program Files (X86); I did it in D drive.
Don't forget to update the path in Environment Variables.
I also installed JAVA Runtime (JRE).
Install git as it is necessary for flutter.
You can Check-in windows command line after installing each (Git, Gradle and flutter doctor). if nothing seems to work Restart the pc after each.
You might try it first, Disable the Gradle plugin and re-enable and restart android studio.
After this when you will compile /run the app it will take a long time please bear with that(at least 15 min just to be sure).
I had the app directory with Read, Write & Modifying permissions still, it was giving that error-
Error code 1 "gradle does not have execution permission. you should change the ownership of the project directory to your user, or move the project to a directory with execute permissions."
so I think it is related to the connection with the plugin.
Hope it helped :-)
Try to set the execution flag on your gradlew file:
chmod +x gradlew
chmod a+rx android/gradlew
This works but for windows you need to install "Git for Windows"
Related
when I run my app I get this error :
Error: ADB exited with exit code 1
Performing Streamed Install
adb: failed to install F:\flutter-project\1\third_app\third_app\build\app\outputs\apk\app.apk: Failure [INSTALL_FAILED_INVALID_APK: Package couldn't be installed in /data/app/com.example.third_app-1: Package /data/app/com.example.third_app-1/base.apk code is missing]
Error launching application on Android SDK built for x86.
update:
I run flutter clear in the terminal and after restarting my computer and executing again, the problem solved
One of the SO post mentioned in the comment:
For Flutter projects, with VS Code editor, go to the project source
folder and delete the "build" folder and start debugging.
This could also be attained by running flutter clean from the terminal. This command helps you delete build cache which is in the /build folder. You can always uses this command when there are any bugs in the build process.
I am having issues installing an apk to my device.
adb install <.apk>
Using the above command returns the following:
5413 KB/s (99747 bytes in 0.017s)
pkg: /data/local/tmp/AppClient.TestOnly.App3.apk
Failure [INSTALL_FAILED_TEST_ONLY]
Any idea on what might cause this issue?
It definitely recognizes the device. Could it be an issue with the apk?
Looks like you need to modify your AndroidManifest.xml
Change android:testOnly="true" to android:testOnly="false" or remove this attribute.
If you want to keep the attribute android:testOnly as true you can use pm install command with -t option, but you may need to push the apk to device first.
$ adb push bin/hello.apk /tmp/
5210 KB/s (825660 bytes in 0.154s)
$ adb shell pm install /tmp/hello.apk
pkg: /tmp/hello.apk
Failure [INSTALL_FAILED_TEST_ONLY]
$ adb shell pm install -t /tmp/hello.apk
pkg: /tmp/hello.apk
Success
I was able to reproduce the same issue and the above solved it.
If your APK is outside the device (on your desktop), then below command would do it:
$ adb install -t hello.apk
I had a similar problem with Android Studio 3.0.0 Beta 7 and could not publish anymore to the play store.
As stated here: https://developer.android.com/studio/run/index.html
Note: The Run button builds an APK with testOnly="true", which means
the APK can only be installed via adb (which Android Studio uses). If
you want a debuggable APK that people can install without adb, select
your debug variant and click Build > Build APK(s).
Same goes for release build, with Android Studio 3 you need to go to Build > Build APK(s) to have a non testable release apk that you can submit to the store.
Add -t install flag, as on the screenshot below:
In my case this mistake was in unstable gradle version. Just use a stable version of gradle (not alpha, not even beta). And it was fixed for me
After searching and browsing all day, the only one works is adding
android.injected.testOnly=false
to the gradle.properties file
I agree with Elisey. I got this same error after opening my project in the 2.4 preview and then opening the same project in android studio 2.3
Fixed the issue by changing this line in build.gradle from
classpath 'com.android.tools.build:gradle:2.4.0-alpha5'
to
classpath 'com.android.tools.build:gradle:2.3.1'
None of the previous post solve my issue. Here is what's happening with me:
I normally load the app from android studio by clicking on the "Run" button. When you do this, android would create an app that's good for debug but not for install. If you try to install using:
adb install -r yourapk
you will get a message that says:
Failure [INSTALL_FAILED_TEST_ONLY]
When this happens, you will need to rebuilt the apk by first clean the build, then select Build->Build APK. See the image bellow:
This APK is ready to be installed either through adb install command or any other methods
Hope this helps
David
Android studio 3.0 generates test only APK.
I have solved the issue by adding the "android:testOnly" property to android manifest's tag.
<application
.....
android:testOnly="false"
android:theme="#style/AppTheme">
And then generated the APK by Android studio3.0 menu:Build-->Build APK(s).
More Info:
https://commonsware.com/blog/2017/10/31/android-studio-3p0-flag-test-only.html
add this line to your ‘gradle.properties’
android.injected.testOnly=false
If you want to test the apk, just add the -t command line option.
Example command:
adb install -t .\app-debug.apk
In my case was by uploading an APK, that although it was signed with production certificate and was a release variant, was generated by the run play button from Android studio.
Problem solved after generating APK from Gradle or from Build APK menu option.
In my case, using Android Studio 4.0, the below solved the issue;
Add to 'gradle.properties' file;
android.injected.testOnly=false
Android 3.6.2 or later
Build >> Build/Bundle apk >> Build apk
Its working fine.
I see the accepted answer but you dont have to actually push the apk and then run the command on adb shell direct adb install with -t flag actually works
adb install -t "path to apk in ur computer"
attaching a screenshot for reference
This works for me:
adb install -t myapk.apk
The easiest to solve this, without reverting to an older gradle version is to add the '-t' option in the run configurations (for pm install).
testOnly='false' had no effect whatsoever. The error is caused by the alpha version of gradle plugin that makes debug APK 'for test only purposes'. The -t option allows such APK to be installed. Setting it in run configuration makes it automatically install you APK as usual.
My finding is as below. If I compile using the Android Studio UI, and the APK generated, I can't just
adb install <xxx.apk>
It will generate Failure [INSTALL_FAILED_TEST_ONLY]
I need to compile it using the gradle i.e. ./gradlew app:assembleRelease. Then only the generated apk, then it can only be installed.
This is because the Android Studio UI Compile, only generate test apk for a particular device, while ./gradlew app:assembleRelease command is the actual apk generation to be installed on all device (and upload to playstore)
I don't know if it's gonna be useful for anyone or not, but I got this error message, when I accidentally tried to build and install my project with test gradle plugin ('gradle:2.4.0-alpha5') version in stable Android Studio version (2.3, not in 2.4 preview 5 version I'd downloaded and installed before).
When I realized my mistake, I launched preview Android Studio version and it built and installed my project without any problem.
As mentioned in documentation:
Android Studio automatically adds this attribute when you click Run
So, to be able to install your apk with adb install <path to apk file> you need to assemble build from terminal: ./gradlew assembleDebug and install with adb. Or just run ./gradlew installDebug to build and install on the device simultaneously.
Build your distribution .apk from Android Studio as follow
Build --> Build Apk(s) (for unsigned build)
Build --> Generate Signed APK ( for signed build)
These option builds the APK with android:testOnly="false" option which allows you to install the APK expicitly into device by the commond.
adb install yourBuilT.apk
What worked for me is performing Refresh all Gradle projects from the Gradle toolbar from the right menu.
PFB the screenshot from Android Studio.
Select Gradle toolbar from the right menu.
Select the Refresh icon
This resolved the issue for me.
Although I am sure Saurabh's answer will work for most other people, I did want to identify the extra steps I had to take in order to get my apk installed.
I tried pushing to the device with the following result:
? adb push AppClient.TestOnly.App3.apk \tmp\
failed to copy 'AppClient.TestOnly.App3.apk' to '\tmp\': Read-only file system
After looking around to change the filesystem RW permissions I ended up executing the following commands:
? adb shell
255|shell#android:/ $ su
shell#android:/ # mount -o remount,rw /
mount -o remount,rw /
I got this when I tried to push again:
? adb push AppClient.TestOnly.App3.apk /tmp
failed to copy 'AppClient.TestOnly.App3.apk' to '/tmp': Permission denied
I was able to push to the sdcard:
? adb push AppClient.TestOnly.App3.apk /sdcard/
3178 KB/s (99747 bytes in 0.030s)
At which point I was able to execute Saurabh's command:
shell#android:/ # pm install -t /sdcard/AppClient.TestOnly.App3.apk
pm install -t /sdcard/AppClient.TestOnly.App3.apk
pkg: /sdcard/AppClient.TestOnly.App3.apk
Success
For me it has worked execute the gradle task 'clean' (under :app, at Gradle pane, usually located at the right) and run again the project.
I tried external project, with multiple apk.
The command from Studio, looked like
adb install-multiple -r ....
Solution -
select console
aste command with -t
If you are looking for a less permanent solution then adding android.injected.testOnly=false to your gradle.properties file and you don't mind using the command line then the following two commands before installation will do:
rm -v **/build/**/AndroidManifest.xml
gradle build
For Windows users: delete all AndroidManifest.xml from all build directories. But not from the src directories so DEL /S is not the best idea.
I got the same issue and no answer helps.
At last, I find there's still an install in my Safe Folder(Or Secure folder depending phone brands), which had not been removed when Android uninstalled the ordinary install. Remove it and this issue fixed.
Hope this can help some guys else!
first remove the unstable version:
adb uninstall problematic-package-name
; and then reinstall the apk.
I'm using react-native 0.43.3 on OSX.
I tried to running app on Android and get message
react-native run-android
Scanning 568 folders for symlinks in /Users/ruci.k/project/mayacrew/supermembers/supermembers/node_modules (5ms)
JS server already running.
Building and installing the app on the device (cd android && ./gradlew installDebug)...
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/android-setup.html
./gradlew installDebug gave me some errors and fixed it all.
Finally build get successed and app is working on Android device.
But react-native run-android command still not work.
Only ./gradlew installDebug command work.
Is there anything can I check to use react-native run-android command?
I can't understand how could it happened.
Running
export JAVA_HOME="/Applications/Android Studio.app/Contents/jre/jdk/Contents/Home"
worked for me
Run the following command
chmod 755 android/gradlew
inside your app root folder
then run
react-native run-android
After you create your react native app ,try
sudo chmod -R 777 node-modules
sudo chmod -R 777 android
export ANDROID_HOME=~/Library/Android/sdk
now run
react-native run-android
Try removing android,ios folders and then do react-native upgrade then try again react-native run-android After that if you get an error like
SDK location not found. Define location with sdk.dir in the local.properties file or with an ANDROID_HOME environment variable.
then create a file named local.properties inside the folder
android
and insert the following line sdk.dir =/path/to/Android/Sdk After this everything should be fine
Note: If you have made some changes in android/ios folder please keep its backup before removing the folders
cd android && sudo ./gradlew clean
This worked for me. Try it out and let me know if it helps folks
I have faced the same issue when I have imported the project from the GitHub.
Follow the below steps to run your react-native project in the Android device from the MAC OS
Remove the 'node_modules' folder from the root project.
Run the below command in the project root folder.
npm install
Move to the android folder in the project root folder.
cd android
Run the following commands one after another to give permissions to gradlew file.
chmod +x ./gradlew
xattr -l ./gradlew
xattr -d com.apple.quarantine ./gradlew
Now, come back to project root folder and run the project in android device.
react-native run-android
Now you can see the launched application on your connected Android device/emulator.
In Ubuntu, I have used this command and it worked for me:
sudo react-native run-android
I had the same issue, and just opened the project in android studio, and that's all. Solved!
this issue come from two reasons
1- Permission issue
How to Fix it
sudo react-native run-android
Or
chmod 755 android/gradlew
2- Mismatch java version with Gradle
make sure you are using Java 8 as $JAVA_HOME environment variable
depending on which terminal you are using to run your code at
For zsh shell, export $JAVA_HOME at ~/.zshenv or ~/.zshrc.
For bash shell, export $JAVA_HOME at ~/.bash_profile or ~/.bashrc.
get installed JDK by this command
/usr/libexec/java_home -V
example for using zsh
vi ~/.zshrc
// paste the java export inside it
export JAVA_HOME="JDK_8_Path_from_previous command"
to save your change
:x
make sure your changes applied
source ~/.zshrc
now for testing
echo $JAVA_HOME
You must change your build.gradle:
compileSdkVersion 28
buildToolsVersion "28.0.2"
minSdkVersion 16
targetSdkVersion 27
and add this line:
implementation "com.android.support:appcompat-v7:28.0.0"
Check whether your emulator is connected or not:
set ANDROID_HOME path: E:\android-sdk-windows
set path D:C:\Program Files\nodejs;C:\Program Files\Java\jdk1.8.0_111\bin;E:\android-sdk-windows\platform-tools
go to folder android in terminal
gradlew clean
run react-native run-android
maybe install watchman?
https://github.com/facebook/react-native/issues/10056
Otherwise, for me I actually use 'npm start' inside of the folder. npm will know to run the right command to start react native because it's in a react native directory.
So what i did was to download this jar file from: 1: https://drive.google.com/file/d/1MHSJx-_0RHRzlrXBLAePKeWKQteke0Um/view?usp=sharing and placed it inside android/gradle/wrapper then i went back to the project directory and did npm install i then changed directory to android by doing: cd android then i ran the following commands
chmod +x ./gradlew
xattr -l ./gradlew
Now i went back to the project directory and ran react-native run-android
Go to C:\Users\ [username]
Rename or delete ".gradle"
Then run "react-native run-android"
So here are the three solution for this bug , from which one will most probably solve your issue :
1: Adding local.properties file in your android folder
https://stackoverflow.com/questions/32634352/react-native-android-build-failed-sdk-location-not-found
2: Try deleting .gradle file and then build (react-native run-android)
3: Might be possible that under SDK tools NDK(side by side) and CMake are not installed .
Steps for the same is
Android Studio which include direction for opening sdk manager
Open android folder in Android Studio
Click on the SDK Manager (which is at the third position from the top left )
After opening SDK manager you have to go to SDK Tools Installation image for NDK and CMake
Under SDK Tools select NDK(side by side) and CMake and press the okay button and let the installation complete .
After the close the Android Studio and react-native run-android.
1 . you should have space in your phone
2 . developer option on
3 . USB debugging option also on
4 . check "adb devices" devices is connected or not
I have to perform these steps to get it running.
First install dos2unix
Run dos2unix ./gradlew inside android folder
then run ./gradlew clean
at last run react-native run-android.
For me, this had to do with running low on RAM om my Mac.
in gradle.properties put -XX:MaxPermSize=4096
for example like this:
org.gradle.jvmargs=-Xmx4096m -XX:MaxPermSize=4096m
After that, it runs again.
What worked for me is,
Uninstalling the previous installed app version on the emulator device, and running react-native run-android after.
Check the error messages carefully. It will give a clue to what went wrong. In my case, after installing expo in my react-native project, the MainApplication.java got corrupted. I made a comparison with the a backup (you can check an earlier working commit), then removed the erroring lines.
After this, it worked.
I have installed android 2.2 in ubuntu 14.04 LTS but when I try to run an android app it shows immediate error:
"Gradle sync failed: Cause: error=13, Permission denied. Consult IDE log for more details (Help | Show Log)".
When I looked into the terminal while I tried to run the android app, it gives below message in terminal:
WARN - roid.tools.ndk.GradleWorkspace - NDK support for project 'MyApp' is disabled because the project doesn't contain any valid native configurations.
I have tried every possible solution on google/stackoverflow but nothing was helpful. Any help/suggestion would be appreciated. Thanks.
This error is sometimes generated due to Java JRE(built-in) failing to execute. Please try the following:
chmod +x android-studio/jre/bin/*
To solve the first problem, did you try to execute the Android Studio as root or using sudo command?
To solve the warn, are you going to use the NDK (Native Development Kit) in your app? If yes, you have installed the NDK? If no, just ignore the warn.
To install the NDK you have to go to
File -> Other Settings -> Default Project Structure
And in the Android NDK Location, click in Download and then continue the installation.
This may happen when your JRE(JDK) files are failing to execute due to no permission. So go to bin folder under your java folder location and make all files executable.
chmod +x /opt/java/java1.8.0_111/bin/*
If you are using built in JRE
chmod +x android-studio/jre/bin/*
I hope this helps.
The permission problem is solved using command 'chmod +x gradlew'. For more explanation refer this link
I am just getting started with with Cordova ( PhoneGap ) and trying to build my first project with it, however I am running into a problem with my compilation step- when I try to build ( in tracking down the problem I broke down the build step into prepare and compile and the former works fine as far as I know ) I see this:
~/Projects/MyProject$ cordova compile android
Compiling app on platform "android" via command "/media/glenatron/local disk/Projects/Cordova/MyProject/platforms/android/cordova/build"
{ [Error: spawn EACCES] code: 'EACCES', errno: 'EACCES', syscall: 'spawn' }
Now from what I can tell this is a permissions problem, but having no Node or Cordova experience yet I am at a loss as to how to troubleshoot it. It looks as though it is trying to spawn another process - maybe the Android SDK? - and it is failing.
Is there a way I can ask Node or Cordova to give me more information on what is going on or is there a log file somewhere that will help me to track down what the problem is?
Edit: I realised cordova has a --verbose switch and when I activated it I get the above output with an additional couple of lines...
Error: spawn EACCES
at errnoException (child_process.js:980:11)
at Process.ChildProcess._handle.onexit (child_process.js:771:34)
Unfortunately, they don't seem to actually give much more information, like which process it can't start.
For me, this has fixed it:
chmod 777 /Applications/Android\ Studio.app/Contents/gradle/gradle-2.2.1/bin/gradle
It's a permission issue, just execute:
chmod 777 "/media/glenatron/localdisk/Projects/Cordova/MyProject/platforms/android/cordova/build"
That should fix the problem.
Using verbose like Solidak suggested works.
cordova build --release --verbose android
The last command was to access /platforms/android/gradlew so i chmod +x that file and it worked.
Its different for every one, I guess. Running --verbose would give you the file that Cordova needs access to. From there you can chmod 777 <file>. The command you should run to figure out the inaccessible file looks like this: cordova build --release --verbose android
I was facing the same issue. In my case, I had put the sample cordova project on a different ext3 partition than home folder. Since the partition was not NTFS, permissions shouldn't have been a problem. But when I tried all suggested methods (changing permissions, making everything executable), none of them worked. This problem went away as soon as I created the sample cordova folder in my home partition.
For MAC users change the name from "Android Studio" to AndroidStudio. My cordova build was taking back slash() in name of android studio so i changed the name of app.
It is working for me.