I am new to android development,
i have made one app which is working perfect on 5.0 and above. but when i tasted .apk with my other phone which is runnnig on micromax 4.4.2 os( 480x800) mobile, it installs but doesnt open. unfortunately app_name has been stop.
so i attatchd my microamx mobile to android studio and tried to run app. everything workd well. why it doesnt work when i shared .apk before??
please help.
apply plugin: 'com.android.application'
android {
compileSdkVersion 24
buildToolsVersion "24.0.2"
defaultConfig {
applicationId "com.example.kalpu.practice1234"
minSdkVersion 14
targetSdkVersion 24
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:24.1.1'
}
This issue is caused by Instant Run. It is not the problem of gradle.
Instant Run will generate the .apk for a specific device and if you use the same .apk for another device it will not work.
If you want to run the same .apk on another device then disable Instant Run and build.
Try below things:
Turn off Instant run from android studio like below.
Then clean project and rebuild it.
Then Run it.
If still you getting problem then post your logcat error.
I wouldn't turn off a useful feature (Instant run)
Generating the signed version just for this can be overkill, especially if it's a new project that hasn't been signed yet.
Simply use the Build APK menu item from the Build menu.
You will get a small popup with a link to open the generated APK in the file manager:
Note: the screenshots are taken in Android Studio 2.2 running in Windows 10.
Related
I'm having some strange issue with Android Studio recently. I'm trying to build a project after few modification in code. But the APK got installed is of old code. (I found this by debugging. When I debugged it was going to empty lines) But all my latest code are saved and it's there. I have tried the following steps which I know.
Delete the build folders of Project and Module manually > Restart Studio > Clean Project > Rebuild Project
Restart Android Studio and (I don't know why I restarted but I did that too)
Invalidate and Cache Restart
At some point I found a issue in XML related to style attribute for button which was like style:attr/buttonBarButtonStyle I later corrected to style:"?android:attr/buttonBarButtonStyle"I hope this change is correct because it don't show any more error.
And finally it doesn't give me any error in stacktrace. Project always shows BUILD SUCCESSFUL
Nothing above helped me.
EDIT 1 : I have updated my Android Support Library to 22.1.1 latest version which released a couple of days ago
EDIT 2 : I uninstalled Android Studio. Deleted Android Studio related folders in C:\Program Files\Android\Android Studio and also deleted C:\Users\MyUserName\.android & .AndroidStudio & .gradle folders. And did fresh install of Android Studio. Later I imported a same project and build it. Again it happens in same way! I have also tried running the same project in other lap and it runs without any problem. I Don't know what else I'm missing here
EDIT 3 : Updating my build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "22.0.0"
signingConfigs {
debug {
storeFile file("./debugkeystore/MyAppDebug.keystore")
}
}
defaultConfig {
applicationId "com.example.myapp"
minSdkVersion 14
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.0.0'
compile 'com.google.android.gms:play-services:6.1.+'
compile 'com.android.support:recyclerview-v7:+'
compile 'com.android.support:support-v4:22.0.+'
compile 'com.android.support:cardview-v7:21.0.+'
}
I just again uninstalled AndroidStudio and clear the registery and made it like a fresh install for the 3rd time and I don't know how but this time it worked! But didn't get what exactly happened!
I solved it by rebuilding the project. Go to the build tab
you should configure Run/Debug Configuration again and add to "Before launch" section "Gradle-aware Make"
that's it
I'm working on an Android Studio project of which I write while constantly move back and forth from laptop to desktop using usb stick. There has been no problem for couple of months I tried this since Android Studio went stable, until today this message keeps showing up no matter how many times I sync the gradle:
Gradle files have changed since last project sync. A project sync may be necessary for the IDE to work properly.
Gradle Console indicates that the build is successful. I also tried cleaning and rebuilding the project, even reinstalling Android Studio, still the message pops out.
What seems to be the problem? Is it not recommended to write a project on multiple Android Studios?
Here's a look of my build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "com.simplifyinc.prodigy"
minSdkVersion 16
targetSdkVersion 21
versionCode 1
versionName "0.3.2"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.3'
compile 'de.hdodenhof:circleimageview:1.2.1'
compile 'com.oguzdev:CircularFloatingActionMenu:1.0.2'
compile 'net.the4thdimension:audio-wife:1.0.3'
compile project('libraries:android-crop')
}
in build.gradle(module:app)
change
build tool,( in my case its 23.0.1)
targetSdkVersion (23) and
in dependency
compile version
("com.android.support:appcompat-v7:23.1.0")
to latest
This happens due to gradle updates
*****Check your PC date*****
You must check your PC or laptop date and time. Correct your date and time will resolve your issue.
each IDE(even if it is the same build number) uses its own metadata. an example would be the location of the Android sdk.when shuffling files between different systems, you would have to make sure that none of the system generated files are copied.
the safest way would be to delete the all the files and folders mentioned in the . gitignore file.
and as in this particular case, the .idea folder.
The modified date for some of my files were set to a future date/time (still havent figured out the cause). Updating the modified time of each file in the project using touch -mt YYYYMMDDhhmm ./* and then the same for those with a . prefix touch -mt YYYYMMDDhhmm ./.* fixed this for me.
this error had happened to me when I changed my computer time carelessly
configer my computer time,and reset the time,this error solved
this error happen when android studio 2.3.3 available and i ignore it, upgrade your android studio to 2.3.3
For Me Below Steps Worked:
1) Delete .idea folder
2) Delete build folder
3) opened each file mentioned in .ignore with notepad and add a space , remove a space and saved file again. this will not effects the file but the trick is notepad changes the Date modified attribute of file.
I'm learning Android Studio, and this error keeps popping up.
(on Emulators)
pkg: /data/local/tmp/com.test.sunshine
Failure [INSTALL_FAILED_UID_CHANGED]
and this
(on Physical Device)
pkg: /data/local/tmp/com.test.sunshine
Failure [INSTALL_FAILED_DEXOPT]
It will prompt to uninstall but nothing happens because the app is not yet installed.
This is the first time I have run any projects on Android Studio. I have Genymotion emulators running and also tried it on my physical device, still with the same results.
I tried transferring the apk to the emulator and installing it from there. Still the same error comes up
I haven't touched any code, this is the precoded Blank Activity with Fragment.
I have the latest Android Studio 1.0 as well as the latest SDKs.
I searched through many questions here and they all suggest to remove the app directly with root. I cant because, the app is not installed. I tried to clean then rebuild, still the same.
I'm beggining to suspect its on the gradle Scritps. I'm new to Android Studio so i dont know any of the workings of gradle.
Here is my gradle script:
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.1"
defaultConfig {
applicationId "com.marlon.sunshine"
minSdkVersion 14
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.2'
}
EDIT
Ok so for anyone still looking into this problem, I haven't found any solution to this, the error just disappeared when I updated Android Studio. So the latest updates of the IDE must have made a solution.
According to the doc: Packing wearable Apps I am using the following code:
dependencies
{
compile 'com.google.android.gms:play-services:5.0.+#aar'
compile 'com.android.support:support-v4:20.0.+''
wearApp project(':wearable')
}
I have generated the release version using the Generate Signed APK. The first time when I install the apk the android wear app is installed properly things are working as required.
I uninstall the app from my mobile. The android wear app also gets uninstalled without any issues, but if I install the app again in my mobile, I don't see the app in the android wear. I am not sure why this is happening. I have tried the same with different apps that that are compatible with android wear those work fine. Install and uninstall and install again, I can see them on android wear emulator.
Here is the build.gradle file from my Application folder:
apply plugin: 'com.android.application'
android {
compileSdkVersion 20
buildToolsVersion '20.0.0'
defaultConfig {
applicationId "com.ysk.notes"
minSdkVersion 9
targetSdkVersion 20
versionCode 3
versionName "1.02"
}
buildTypes {
release {
runProguard true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies
{
compile fileTree(include: ['*.jar'], dir: 'libs')
compile project(':FacebookSDK')
compile files('libs/activation.jar')
compile files('libs/additionnal.jar')
compile files('libs/mail.jar')
compile 'com.google.android.gms:play-services:5.0.+#aar'
compile 'com.android.support:support-v4:20.0.+'
wearApp project(':Wearable')
configurations
{
all*.exclude group: 'com.android.support', module: 'support-v4'
}
}
Can somebody let me know where I am going wrong?
I had this problem where the wear app wouldn't install. So I made sure the mobile app was installed (after exporting singed APK and doing an ADB INSTALL), then opened the Android Wear app, pressed the gears icon at the top and then selected Resync apps.
I have two suggestions for you that may help.
1) You mention you're using the wear emulator instead of a real watch device. I have experienced issues with connecting and syncing the emulator. Try resetting the emulator and reconnecting through Android Wear on your phone (aka running adb -d forward tcp:5601 tcp:5601) again.
2) There seems to be some caching of versionCode on the Phone and it uses that to know if it needs to resync and update the app on the watch. Try incrementing your versionCode and see if that helps.
Hope one of those helps.
Try unpair and restore factory rest .
It will solve the problems and sync all the data.
It worked for me
I am going to start develop application for fire TV i can create an application using Eclipse successfully, But when i try the same procedure to create new application which compile with Firetv SDK got some Gradle error on android studio.. i am stuck with this issues for around one week.
The error is Gradle app neame project refresh failed:
Unexpected lock protocol found in lock file. Expected 3, found 0.
Gradle settings
I searched lot about this error in google but cant get any solution
Sorry for my bad English.
My even log says:
Gradle 'Test' project refresh failed:
Unexpected lock protocol found in lock file. Expected 3, found 0.
Gradle settings
My build gradle
apply plugin: 'android'
android {
compileSdkVersion 17
buildToolsVersion "19.0.3"
defaultConfig {
minSdkVersion 17
targetSdkVersion 17
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
}
My case, delete ~/.gradle/ and suddenly all working well again.
good luck!
Invalidate Caches And Restart Also Works. Try It Out By Going
To File and selecting Invalidate caches and restart
Just go to Android Studio -> File -> Close project. After closing the project,reopen it afresh. This solved the problem for me.
I couldn't understand about ~/.gradle/ folder... but now I got it
and solved! delete here folder!