Test running failed:
Permission Denial: starting instrumentation ComponentInfo{com.xxx.taskmanager.warehouse.tests/android.test.InstrumentationTestRunner} from pid=766, uid=766 not allowed because package com.xxx.taskmanager.warehouse.tests does not have a signature matching the target com.xxx.taskmanager.warehouse
Empty test suite.
This is my app.gradle file
apply plugin: 'android-sdk-manager'
apply plugin: 'com.android.application'
android {
signingConfigs {
release
{
keyAlias 'xxx'
keyPassword 'xxx'
storeFile file('../keystore.jks')
storePassword 'xxx'
}
}
compileSdkVersion 16
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "com.xxx.taskmanager.warehouse"
minSdkVersion 16
targetSdkVersion 16
versionCode 3
versionName "3.0"
testApplicationId "com.xxx.taskmanager.warehouse.tests"
}
packagingOptions {
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/LICENSE'
exclude 'LICENSE'
exclude 'NOTICE'
exclude 'META-INF/NOTICE'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/ASL2.0'
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.release
}
}
applicationVariants.all { variant ->
variant.outputs.each { output ->
output.outputFile = new File(
output.outputFile.parent,
"FLO_HANDHELD_V${variant.versionName}.apk"
)
}
}
variantFilter { variant ->
if(variant.buildType.name.equals('debug')) {
variant.setIgnore(true);
}
}
productFlavors {
production_b2b {
applicationId "com.xxx.taskmanager.warehouse"
minSdkVersion 16
targetSdkVersion 16
versionCode 3
versionName "3.1-Prod-B2B"
}
stage_b2b {
applicationId "com.xxx.taskmanager.warehouse"
minSdkVersion 16
targetSdkVersion 16
versionCode 3
versionName "3.1-Stage-B2B"
}
production_b2c {
applicationId "com.xxx.taskmanager.warehouse"
minSdkVersion 16
targetSdkVersion 16
versionCode 3
versionName "3.1-Prod-B2C"
}
stage_b2c {
applicationId "com.xxx.taskmanager.warehouse"
minSdkVersion 16
targetSdkVersion 16
versionCode 3
versionName "3.1-Stage-B2C"
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile files ('libs/android-support-v7-appcompat.jar')
compile files('libs/android-support-v4.jar')
compile project(':taskmanagerlib')
compile files('libs/DataCollection.jar')
androidTestCompile fileTree(dir: 'libs', include: 'robotium-solo-5.3.0.jar')
}
task copyTask(type: Copy) {
from 'build/outputs/apk'
into 'apks'
exclude '**/*-unaligned.apk'
}
task deleteApk(type: org.gradle.api.tasks.Delete){
// delete 'apks'
}
task appBuild(dependsOn: ['deleteApk','clean', 'assembleRelease', 'copyTask']){
assembleRelease.mustRunAfter deleteApk
clean.mustRunAfter deleteApk
copyTask.mustRunAfter assembleRelease
}
I think this error is happening because I have not declared the signingConfigs for test package. If so , how do I declare it. ?
Please help!!
I have solved the issue. Answering it so that it can be useful for someone else.
Solution is for Android Studio :
For the tests to run , the build variant should be debug. Build Variants window is present in the left side of the android studio, if not activated then activate it by click on Build variants tab present on the left side of the android studio.
You either have to change your build variant to debug, or add a testBuildType to your android tag inside your build.gradle file. Like this:
android {
...
testBuildType "release"
}
Clean Your Project.
Uninstall app if already install.
Now Run your project.
It's Completely Working for me.
Had the same problem even with Android Studio 3.x years later. Previous answers did not work for me.
Only cure was to explicitly add the permissions to the test app on the phone.
It worked for me when changed Startapp code to use apk file instead of installed App.
i.e. from :
From :
return GetApp().InstalledApp(Settings.AUTPackageName).EnableLocalScreenshots().ConnectToApp();
To:
return GetApp().ApkFile(Settings.AUTPath).EnableLocalScreenshots().ConnectToApp();
Related
I just imported a project, but when i try to enter design view this shows up:
My current gradle version is the latest 26.0.2 by the way. I'm not sure what to do, anyone have an idea?
Here are some Gradle Scripts:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion
defaultConfig {
applicationId "com.example.Ron.myapp"
minSdkVersion 15
targetSdkVersion 23
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:23.1.1'
compile 'com.android.support:design:23.1.1'
}
and
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
I solved the problem myself. I upgraded the compileSdkVersion aswell as the minSdkVersion along with the dependencies. It now looks like this:
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
buildToolsVersion
defaultConfig {
applicationId "com.example.Ron.myapp"
minSdkVersion 18
targetSdkVersion 26
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:26.0.2'
compile 'com.android.support:design:26.0.2'
compile 'com.android.support:cardview-v7:26.0.2'
}
please update your support lib and compileSdkVersion like below.
compileSdkVersion = 25
buildToolsVersion = "25.0.2"
minSdkVersion = 18
// Library versions
supportLibraryVersion = "25.0.0"
also add ConstraintLauout gradle in gradle file.
compile 'com.android.support.constraint:constraint-layout:1.0.2'
For More details please check : https://stackoverflow.com/a/45115111/1343788
known problem
just add
compile 'com.android.support.constraint:constraint-layout:1.0.2'
in your gradle file,
it will fix it
I'm following Create Hello-JNI With Android Studio.
MAC OX 10.11.5
Android Studio 2.2 stable
java version: 1.7.0_79
gradle-2.14.1
Here's my app.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "com.chenql.helloandroidjni"
minSdkVersion 14
targetSdkVersion 23
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
ndk {
moduleName "hello-android-jni"
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:23.3.0'
compile 'com.android.support:design:23.3.0'
testCompile 'junit:junit:4.12'
}
Here's the error:
The Error Message
Error:(20, 0) Could not find method ndk() for arguments [build_13jh6qtzl4f08f8c1of3mvsys$_run_closure1$_closure5#5b127949] on project ':app' of type org.gradle.api.Project.
Open File
It turns out that this code
ndk {
moduleName "hello-android-jni"
}
should be placed under "defaultConfig" block:
defaultConfig {
applicationId "com.chenql.helloandroidjni"
minSdkVersion 22
targetSdkVersion 23
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
ndk {
moduleName "hello-android-jni"
}
}
instaed of after "buildTypes" block.
Upgrading to a newer version of the Gradle plugin solves
You just add the following code in android/app/build.gradle
android {
ndkVersion rootProject.ext.ndkVersion //<-- add line
compileSdkVersion rootProject.ext.compileSdkVersion
And in android/build.gradle
buildscript {
ext {
buildToolsVersion = "29.0.3"
minSdkVersion = 21
compileSdkVersion = 31
targetSdkVersion = 30
ndkVersion = "22.1.7171670 || {{use your ndk_version}}" //<-- add line
Thats it. Rebuild the app
Comment or delete ndkVersion 'version number' at build.gradle
I migrate my android app from eclipse to Android Studio. During this "migration" I decided to split my project in 4 modules: GUI module, engine module, commons module and resources module.
The problem is that I cannot include v4 or v7 libs... It does not recognize the import:"import android.support.v4."
Below are the gradles:
1.Genral Gradle:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.1.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
1.Gradle for GUI module(main module):
apply plugin: 'com.android.application'
dependencies {
compile 'com.android.support:support-v4:+'
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.0.0'
compile project(':audiorecengine')
compile 'com.google.android.gms:play-services:7.0.0'
}
android {
compileSdkVersion 22
buildToolsVersion "22.0.0"
defaultConfig {
applicationId "com.audioRec"
minSdkVersion 10
targetSdkVersion 22
versionCode 73
versionName "4.0.4"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors {
lite {
applicationId = "com.audioRec"
versionCode 73
versionName "4.0.4"
}
pro {
applicationId = "com.audioRec.pro"
versionCode 13
versionName "3.0.3"
}
}
}
Gradle for engine module:
apply plugin: 'com.android.library'
android {
compileSdkVersion 22
buildToolsVersion "22.0.0"
defaultConfig {
minSdkVersion 11
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 project(':audioreccommons')
}
It appears that the issue was caused by GooglePlayService lib which already contained the v4 support library. The solution was to exclude support-v4 when compiling playServices.
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile project(':audiorecengine')
compile ('com.google.android.gms:play-services:7.0.0'){
exclude module: 'support-v4'
}
}
Also I removed v4 from gradle dependency because it is already contained by the v7 support lib
I got the following error in Android Studio while creating project...
Error:(24, 0) Project with path ':wear' could not be found in project ':mobile'.
This is my build.gradle file code, I want to resolve this issue. Any help appreciated...
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "com.user.usereventdemo"
minSdkVersion 16
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'])
wearApp project(':wear')
compile 'com.android.support:appcompat-v7:21.0.3'
compile 'com.google.android.gms:play-services:6.5.87'
}
Looking at your settings.gradle, is it including :wear,?
if you don't want codes of wear, then delete :wear, and wearApp project(':wear') in your build.gradle.
if you want, then you have to find codes of wear, I'm afraid.
Under Gradle Scripts folder in Android Studio, locate "settings.gradle".
Open it and add ':wear' to the end of include statement.
It should look something like this:
include ':mobile', ':glass', ':wear'
I have setup ActiveAndroid as per the wiki instructions using latest version of AndroidStudio. I am using product Flavours. This is my gradle build file:
apply plugin: 'android'
apply plugin: 'android-apt'
apt {
arguments {
androidManifestFile variant.processResources.manifestFile
resourcePackageName android.defaultConfig.packageName
}
}
android {
compileSdkVersion 19
buildToolsVersion "19.0.3"
defaultConfig {
minSdkVersion 8
targetSdkVersion 19
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
productFlavors {
a {
packageName "com.a.a"
}
b {
packageName "com.a.b"
}
c {
packageName "com.a.c"
}
}
}
dependencies {
apt "org.androidannotations:androidannotations:3.0+"
compile "org.androidannotations:androidannotations-api:3.0+"
compile 'com.android.support:support-v4:19.0.1'
compile 'com.android.support:appcompat-v7:19.0.1'
compile fileTree(dir: 'libs', include: ['*.jar'])
}
Gradle build files but when I compile/go to debug on the device I receive two errors:
Error:: The generated null.R class cannot be found
and
Error:Execution failed for task ':ml:compileADebugJava'.
Compilation failed; see the compiler error output for details.
I have tried numerous setups for my build file but cannot for the life of me get it work. Also when I try and change my AndroidManifest from:
android:name="com.a.a.MainActivity"
to
android:name="com.a.a.MainActivity_"
it states that class cannot be found.
I am using latest version of Gradle and latest version of ActiveAndroid.
Any help would be much appreciated.
I know its late, but it might help someone.
This happens when you modify the applicationId. The script provided in example assumes that you have declared "android.defaultConfig.applicationId". In most of the cases its null, and hence it generated null.R. Either you can define the variable or change the code to following:
defaultConfig {
// Rest of Config
javaCompileOptions {
annotationProcessorOptions {
arguments = ["resourcePackageName": "<Original Package Name>"]
}
}
}
Note that original Package name should be same as the location of R in your activity.
Hope it helps!
I have just got into this same problem, solved by adding packageName to the defaultConfig:
Sample:
defaultConfig {
packageName "com.example.myapp"
minSdkVersion 8
targetSdkVersion 19
versionCode 1
versionName "1.0"
}
Change com.example.myapp according to the name specified in your AndroidManifest.xml.
Hope this helps.
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "com.your.app"
minSdkVersion 14
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
apt {
arguments {
androidManifestFile variant.outputs[0].processResources.manifestFile
resourcePackageName android.defaultConfig.applicationId
}
}
It works for me.
I was facing this problem, so I just removed this line:
resourcePackageName android.defaultConfig.packageName
and it worked.
apt {
arguments {
androidManifestFile variant.outputs[0].processResources.manifestFile
resourcePackageName android.defaultConfig.applicationId
}
In my case, It Worked.
change the applicationId==package in the manifest.
100% success.
I had the same problem. I've update the build.gralde file as follow.
For Java I've added:
android {
defaultConfig {
applicationId "<your.application.id>"
javaCompileOptions {
annotationProcessorOptions {
includeCompileClasspath true
arguments = ["resourcePackageName": android.defaultConfig.applicationId]
//arguments = ['androidManifestFile': variant.outputs[0].processResources.manifestFile]
}
}
}
}
For Koltin I've added:
kapt {
arguments {
arg("resourcePackageName", android.defaultConfig.applicationId)
//arg("androidManifestFile", variant.outputs[0]?.processResources?.manifestFile)
}
correctErrorTypes = true // add this if you use data binding
}