Android Studio: Failure [INSTALL_FAILED_INVALID_APK] - android-studio

I have the following problem when running my app:
Waiting for device.
Target device: samsung-gt
Uploading file
local path: C:\Users\kwmaster\AndroidStudioProjects\Count500\app\build\outputs\apk\app-debug.apk
remote path: /data/local/tmp/xxxxx
Installing xxxxx
DEVICE SHELL COMMAND: pm install -r "/data/local/tmp/xxxxx"
pkg: /data/local/tmp/xxxxx
Failure [INSTALL_FAILED_INVALID_APK]
Why did it not let me install the apk???

In my case (I have a rooted device) and when I rooted, something happened with my permission of /data/local/tmp and they have been changed, so adb can't get access temp file.
How I solved it:
Install RootExplorer
Create new tmp folder on SD card
Long press on tmp folder, and select "Link to this folder" (last option in menu)
Go to /data/local/ and tap button "Create link" from bottom

For those that will encounter this problem in the future just go in build.gradle and put at applicationId just put a name with a point betwen 2 words.Example: First.Test

As AndroidGuy thought there was a problem in build.gradle - the gradle version ws wrong.
I also have changed in the settings to use the default gradle wrapper and not the local stuff!!!

I was also having this problem because of changing package name. So do check your package and sub packages names and also in manifest file where activities defined with package name.

when I cd /data/local/tmp, I found my project name in the folder.
So I solved the problem as follows:
adb shell
cd /data/local/tmp
rm -r your project name. For example: rm com.example.pc002.intenttest1

I was facing a similar issue. I fixed it by first closing the Android Studio project and then deleting the .gradle folder within the project.This, forced Android Studio to rebuild it when I opened it again, and then it fixed the issue.

Related

Android Studio- git Clone: "Unable to create destination directory"

I am trying to clone a github repository from my account in my Android studio, but each time I try to clone it by
VCS -> get from version control -> URL, an error message pops up with message:
"Clone: Unable to create destination directory".
What can I do?
Go to your Android Studio installation directory (usually Program Files/Android/Android Studio).
Go to the bin folder.
Right click studio64.exe (or studio.exe if you're using the 32bit
version) and run it as an administrator.
Now clone should work just fine.
I'm sure there is a better solution out there but right now, this should work.
Check your folder path.
In my case, my directory name had whitespace, so I changed the folder name from namu nikam to namunikam.
After that, github cloned the project.
The project error message was:
Cmd doesn't allow us to run commands with any space in between
Sometimes we use underscores between words, like namu_nikam.

Gradle Error: Path is not a readable directory for an Android Project saved in OneDrive

I tried to use a OneDrive folder to store my Flutter project [Windows 10, Android Studio]. I then made edits to it on another machine [same configurations]. The project compiled fine on the first machine initially and on the second one after the changes. Running it on the first machine again after the changes I get the below error:
Execution failed for task ':app:processDebugResources'.
Path "build/[package]/intermediaries/compiled_local_resources" is not a readable directory.
I've tried a number of solutions mentioned in similar, though not equivalent issues:
Updating Android Studio
Running Android Studio as Administrator
Removing the [package] from my dependencies (this resulted in a
different package being identified in the error message).
Pressing File -> Invalidate Caches / Restart...
Commenting out
"org.gradle.jvmargs=-Xmx1536M" in gradle.properties
Doing:
cd android
gradlew clean
None of this worked.
I had the same problem today:
Path "build/[package]/intermediaries/compiled_local_resources/debug/out" is not a readable directory.
I was able to fix this issue by deleting the .gradle and rebuilding the project.
All I did was create the (empty) directory that it was looking for and it built fine afterward.
mkdir -p compiled_local_resources/debug/out
I had the same issue, came out of no where and it really shouldn't make the build fail... but all I did was create the (empty) directory that it was looking for and it built fine afterwards.
In the end the only thing that worked for me was pushing the project up to a Git remote and cloning it from there into another (local) directory.
[not sure this counts as a solution but nothing else worked for me after a long agonising search so hopefully it helps someone]
I know the OP had Windows, but if it helps anyone else in the future:
On Mac OS I discovered (the hard way) that Android Studio and Flutter do not play nice with being stored in iCloud! I noticed that some files weren't available locally and that's what was causing the problem for me. I moved my project out of iCloud (forcing it to download the missing files forever) and then it was fine.
Deleting the android/.gradle folder worked for me.
+1 also to the #1 answer (Vadow). As I do not have 50 points yet was not able to add this as a comment, so will have to post separately.
Like the OP, I have two machines - and got into trouble (Synology Drive). Vadow's solution worked for me, but I also had to do:
Flutter Clean
Flutter Pub Get
on the terminal and from within the project directory to get things follow back up and running.
Thank you Stackoverflow, and thank you Vadow!

How to fix "couldn't follow symbolic link" in Android Studio?

I'm now running an Android App project on Windows and running into the condition
Error:Could not list contents of
'D:\source\App\src\main\res\drawable'. Couldn't follow symbolic link.
after did the clean build.
Android Studio states the drawable file is a broken symbolic link.
I just check other related post online but still cannot figure out what does that mean, why is that happened, and how to fix it. Can anyone help to give me a clue to fix it?
Next time to save time you can run the following command:
find . -type l -exec test ! -e {} \; -delete
Still do not know the real reason but problem solved by re-checkout source.
Clean build did not work so I guess there's just something wrong in the project build-up steps.
Removing .bin did not work, but rm -rf node_modules && npm install did the trick.
Navigate to node modules folder of particular package, and delete the .bin folder
Eg:
Task :app:bundleReleaseJsAndAssets FAILED
FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task ':app:bundleReleaseJsAndAssets'.
Could not list contents of '/home/centillion/Documents/CMC/cmc-mobile-repo/node_modules/react-native-image-slider/node_modules/.bin/flow'. Couldn't follow symbolic link.
For this case, navigate to node modules/react-native-image-slider/node modules and delete .bin folder and rerun.
NOTE: To view hidden folders, press CTRL + H
I have always resolved this issue by using
unlink followed by the path where it's not finding symbolic link.
example: unlink ./bin/uuid

no clean option in android studio

I found no option for clean project in build in android studio. what is reason for that? or is there different way to clean the project in android studio
Make sure you are looking a the correct directory. I also thought clean was missing when I looked under the root directory. Turns out it see example is located under the :app directory.
Open the Gradle side panel on the right. Select app->Tasks->build->clean
This problem can occur when you import the root directory rather than the project file. If you imported the file, make sure you select the correct file:

How to run NDK samples?

Sorry to ask such a noob question, but the NDK documentation is wrong (r7b):
If you are developing in Eclipse with ADT, use the New Project Wizard
to create a new Android project for each sample, using the "Import
from Existing Source" option and importing the source from
<ndk>/apps/<app_name>/project/. Then, set up an AVD, if necessary, and
build/run the application in the emulator.
There is no "apps" folder, and the samples do not contain a "project" folder. So ... what is the correct way to run a sample?
Also, can I configure Eclipse to build the C++ portion of the code automatically?
Click File | New | Project...
Choose Android project, Next
Project Name: This is the project name shown in Package Explorer. It is just a string stored in the .project file that Eclipse creates. No file or folder is created with this name, and the output binaries do not seem to contain this name.
Click "Create project from existing source"
Location: choose the project's root folder, e.g. .../android-ndk-r7b/samples/bitmap-plasma
Click Next and choose your target API. Eclipse does not seem to allow this to be changed later, at least not from the GUI. I don't know why Eclipse does not simply get this information from <uses-sdk> in AndroidManifest.xml or from the "target" line in default.properties. I also don't know why the two may be different (e.g. in the bitmap-plasma sample, target=android-9 but <uses-sdk android:minSdkVersion="8"/>.)
Click next and consider changing the "Package Name" field which defaults to "your.package.namespace". However, the project will run fine if you do not change this field. Leave "Create Activity" and "Create a Test Project" unchecked.
Click Finish. Eclipse will create numerous extra files (e.g. .classpath, .project, project.properties) and folders (bin, gen, assets) alongside the existing code. That's in addition to the output folders created by ndk-build (obj and libs).
Eclipse won't build the native code by itself, but it will automatically deploy the native code (e.g. libplasma.so) if it is aware of it. After you build the native code on the command line, e.g.:
C:\...\android-ndk-r7b\samples\bitmap-plasma>..\..\ndk-build
Gdbserver : [arm-linux-androideabi-4.4.3] libs/armeabi/gdbserver
Gdbsetup : libs/armeabi/gdb.setup
Gdbserver : [arm-linux-androideabi-4.4.3] libs/armeabi-v7a/gdbserver
Gdbsetup : libs/armeabi-v7a/gdb.setup
"Compile thumb : plasma <= plasma.c
SharedLibrary : libplasma.so
Install : libplasma.so => libs/armeabi/libplasma.so
"Compile thumb : plasma <= plasma.c
SharedLibrary : libplasma.so
Install : libplasma.so => libs/armeabi-v7a/libplasma.so
Right-click your project and choose "Refresh", otherwise Eclipse might fail to upload the native code when it starts the emulator.
Finally, to run the sample, right-click the project and choose Run As | Android application. See here about choosing which emulator is used.
See here about configuring Eclipse to build the native code automatically.
I am curious why NDK produces two *.so files with very different sizes for each ABI, e.g. it creates libs/armeabi-v7a/libplasma.so (15 KB) but also obj/local/armeabi-v7a/libplasma.so (63 KB). Anyone know the difference?
Instead of going the long winded way ( seasoned programmer love it - but for beginners). There is a way to build the native library in Eclipse and NDK.
1> First you need to make sure NDK path is correct in Windows -> Preference -> (tabs) Android -> NDK - If not set - point it to ndk directory.
2> Assuming you have you imported project as described above (New | Project | Create from existing code) - You right click the project and go to " Android Tools -> Add Native Support ..". If the path is set it will build the example. And then you can deploy it to the device or AVM by pressing the play button.
SOURCE
I'm working with Eclipse ADT and Android ndk 5b. My correct path to the project is android-ndk-5b/samples/project
When you import from existing source you have to choose a correct target, I use Android 2.3.3.
After, I've updated my project from command line, look this link, http://developer.android.com/sdk/ndk/overview.html
From the samples path write: android update project -p . -s and $Your_Path_Android_ndk/ndk-build
Finally, only run as android app in Eclipse and it's done
It seems that with Eclipse Juno, you can now
Click File | New | Project...
Under Android category select Android Project from Existing Code and click Next.
In Root Directory you can then browse and confirm your sample project location.
From here, Eclipse can automatically detect the jni and find the projects.
If this didn't work, go to terminal or command prompt and navigate to your project root directory (where you see jni folder). Then input
android update project -p . -t <your target level>
Here should be, e.g., android-9
After this, try again the initial steps.

Resources