I'm struggling to get Robotium to work on the gradle-based Android Studio and I can't find the way to run the test with gradle CLI.
I Placed robotium.jar "robotium-solo-5.4.1.jar" into the libs folder, Added as library.
In the src folder I created another folders androidTest->java->package for the test source with the same name as app’s package name-> Test.java
"java" (inside "androidTest") is a green color.
UI: as usual using Android Studio Run menu - working.
console: in the terminal enter the following command: gradlew connectedAndroidTest = not working.
I also tried "gradlew test", test results get generated in build/test-report, but they show that no tests were found.
I want to run Robotium test with gradle CLI without connecting device, because I want to run tests in the Android emulator in CircleCI.
Is there a problem on my build.gradle / test file or is there a something I missing ?
I would really appreciate any help!
***** This is my build.gradle file
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
dexOptions {
// jumboMode true
javaMaxHeapSize "2g"
}
defaultConfig {
applicationId 'net.example'
minSdkVersion 14
targetSdkVersion 22
versionName '2.8.1'
versionCode 2801
multiDexEnabled true
}
buildTypes {
debug{
debuggable true
jniDebuggable true
}
release {
debuggable false
jniDebuggable false
minifyEnabled true
proguardFiles 'proguard-coda.txt', 'proguard-rules.pro'
}
}
productFlavors {
}
packagingOptions {
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/LICENSE'
exclude 'META-INF/NOTICE'
}
lintOptions {
disable 'MissingTranslation'
}
sourceSets {
androidTest {
java.srcDirs = ['src/androidTest/java']
}
}
}
dependencies {
// Included library modules
...
// My regular dependencies
...
compile fileTree(include: ['*.jar'], dir: 'libs')
// Test dependencies
androidTestCompile 'com.jayway.android.robotium:robotium-solo:5.4.1'
androidTestCompile fileTree(dir: 'libs', include: 'robotium-solo-5.4.1.jar')
}
***** Robotium test file in the Location : app->src->androidTest->java->package name->Test.java
package net.example;
import com.robotium.solo.*;
import android.test.ActivityInstrumentationTestCase2;
import android.view.View;
import java.util.ArrayList;
#SuppressWarnings("rawtypes")
public class Test extends ActivityInstrumentationTestCase2 {
private Solo solo;
//Debug Logcat Tag for filtering
private static final String TAG = "RoboDebug";
private static final String LAUNCHER_ACTIVITY_FULL_CLASSNAME ="net.example.exampleActivity";
private static Class<?> launcherActivityClass;
static{
try {
launcherActivityClass = Class.forName(LAUNCHER_ACTIVITY_FULL_CLASSNAME);
} catch (ClassNotFoundException e) {
throw new RuntimeException(e);
}
}
#SuppressWarnings("unchecked")
public Test() throws ClassNotFoundException {
super(launcherActivityClass);
}
public void setUp() throws Exception {
super.setUp();
solo = new Solo(getInstrumentation());
getActivity();
}
#Override
public void tearDown() throws Exception {
solo.finishOpenedActivities();
super.tearDown();
}
public void testRun() {
//Wait for activity: 'net.example.exampleActivity'
solo.waitForActivity("exampleActivity", 5000);
//Wait for activity: 'coda.RootActivity'
//!!!!!!!!
assertTrue("RootActivity is not found!", solo.waitForActivity("RootActivity"));
//Set default small timeout to 60000 milliseconds
//Click on Beauty
solo.clickOnText(java.util.regex.Pattern.quote("Beauty"));
ArrayList<View> dig = solo.getViews();
android.util.Log.d(TAG, "Dig is: " + dig);
}
}
Related
I have a very weird problem with Android Studio Chipmunk. It doesn't recognize java syntax and all IDE features are disabled, like autocomplete, autoimports, etc., but only in one of my projects. If I open other projects It works good, but with one of them It doesn't work. It's like the project were only c++, because if I try to create a new class (right button -> New), only "c++ class" is shown, and "java class" option is missing.
I have tried all answers I have found in stackoverflow but without success:
Invalidate caches and restart
Clean, rebuild, make.
Check Power save mode is unchecked.
Delete .idea folders, and other folders like .gradle, etc.
Rename some folders in users//appdata/local...android
File -> sync project with gradle files
Update all dependencies in gradle file to latest versions.
Check gradle-wrapper.properties
I don't know what else I could do. This is my build.gradle, but ask me for another file if it were required.
buildscript {
repositories {
google()
mavenCentral()
jcenter()
maven { url "https://jitpack.io" }
}
dependencies {
classpath 'com.android.tools.build:gradle:7.2.2'
classpath 'com.google.gms:google-services:4.3.13'
classpath 'com.google.firebase:firebase-crashlytics-gradle:2.9.1'
}
}
apply plugin: 'com.android.application'
repositories{
mavenCentral()
}
allprojects {
repositories {
google()
jcenter()
maven { url "https://maven.google.com" } // <<<< REPOSITORY HERE
maven { url 'https://maven.fabric.io/public' }
}
}
apply plugin: 'com.android.application'
dependencies {
implementation 'com.google.firebase:firebase-crashlytics:18.2.13'
implementation 'com.google.firebase:firebase-analytics:21.1.1'
implementation 'com.google.firebase:firebase-messaging:23.0.8'
implementation files('libs/ZSDK_ANDROID_API.jar')
implementation files('libs/ZSDK_ANDROID_BTLE.jar')
def acraVersion = '5.9.6'
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.jpardogo.materialtabstrip:library:1.1.1'
implementation 'androidx.appcompat:appcompat:1.5.0'
implementation 'com.github.shell-software:fab:1.1.2'
implementation 'androidx.recyclerview:recyclerview:1.2.1'
implementation 'com.daimajia.swipelayout:library:1.2.0#aar'
implementation 'com.google.android.material:material:1.6.1'
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'com.github.rey5137:material:1.3.1'
implementation 'com.chauthai.swipereveallayout:swipe-reveal-layout:1.4.1'
implementation 'com.google.android.gms:play-services-vision:20.1.3'
implementation 'androidx.mediarouter:mediarouter:1.3.1'
implementation 'androidx.appcompat:appcompat:1.5.0'
implementation 'com.google.firebase:firebase-core:21.1.1'
implementation "androidx.viewpager:viewpager:1.0.0"
// this line must be included to use FCM
implementation 'androidx.multidex:multidex:2.0.1'
// ACRA
implementation "ch.acra:acra-mail:$acraVersion"
implementation "ch.acra:acra-dialog:$acraVersion"
// Debug implementation base de datos
debugImplementation 'com.amitshekhar.android:debug-db:1.0.6'
}
android {
compileSdkVersion 33
buildToolsVersion '33.0.0'
defaultConfig {
applicationId "com.mycompany.myproject"
targetSdkVersion 33
minSdkVersion 19
setProperty("archivesBaseName", "myproject")
multiDexEnabled true
vectorDrawables.useSupportLibrary = true
}
compileOptions.encoding "ISO-8859-1" // For Spanish [Otherwise strange accents]
compileOptions {
sourceCompatibility JavaVersion.VERSION_11
targetCompatibility JavaVersion.VERSION_11
}
// Specifies a flavor dimension.
flavorDimensions "color"
productFlavors {
}
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
// Move the tests to tests/java, tests/res, etc...
androidTest.setRoot('tests')
// Move the build types to build-types/<type>
// For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ...
// This moves them out of them default location under src/<type>/... which would
// conflict with src/ being used by the main source set.
// Adding new build types or product flavors should be accompanied
// by a similar customization.
debug.setRoot('build-types/debug')
release.setRoot('build-types/release')
}
buildTypes {
release {
debuggable false
minifyEnabled true
proguardFile getDefaultProguardFile('proguard-android-optimize.txt')
}
}
productFlavors {
defaultFlavor {
proguardFile 'proguard-rules.txt'
}
}
signingConfigs {
release {
v2SigningEnabled false
}
}
android {
lintOptions {
abortOnError false
}
}
packagingOptions {
resources {
excludes += ['META-INF/LICENSE.txt', 'META-INF/NOTICE.txt', 'META-INF/NOTICE', 'META-INF/LICENSE', 'META-INF/DEPENDENCIES']
}
}
ndkVersion '25.1.8937393'
}
apply plugin: 'com.google.gms.google-services'
apply plugin: 'com.google.firebase.crashlytics'
I searched a lot on the web, but couldn't find a solution. I have a a project named VolleyLib with a library module named volleylib. I'm trying to publish the library on mavenLocal repo, but when build the project no publishing task is executed (only prepareLintJarForPublish). And of course nothing goes into .m2 folder (which I created myself after installed maven...). I can't really get why and what is wrong. Probably something's missing...
Here's my build.gradle for volleylib module:
plugins {
id 'com.android.library'
id 'maven-publish'
}
android {
compileSdk 31
defaultConfig {
minSdk 22
targetSdk 31
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles "consumer-rules.pro"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_11
targetCompatibility JavaVersion.VERSION_11
}
}
dependencies {
implementation 'androidx.appcompat:appcompat:1.4.1'
implementation 'com.google.android.material:material:1.4.0'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
implementation 'com.android.volley:volley:1.2.1'
implementation 'com.fasterxml.jackson.jr:jackson-jr-annotation-support:2.13.1'
implementation 'androidx.room:room-common:2.4.1'
annotationProcessor 'androidx.room:room-compiler:2.4.1'
implementation 'androidx.room:room-coroutines:2.1.0-alpha04'
implementation 'androidx.room:room-runtime:2.4.1'
implementation 'androidx.room:room-migration:2.4.1'
implementation 'androidx.room:room-rxjava2:2.4.1'
}
afterEvaluate {
publishing {
publications {
// Creates a Maven publication called "release".
release(MavenPublication) {
// Applies the component for the release build variant.
from components.release
// You can then customize attributes of the publication as shown below.
groupId = 'com.example.VolleyLib'
artifactId = 'final'
version = '1.0'
}
// Creates a Maven publication called “debug”.
debug(MavenPublication) {
// Applies the component for the debug build variant.
from components.debug
groupId = 'com.example.VolleyLib'
artifactId = 'final-debug'
version = '1.0'
}
}
repositories {
mavenLocal()
}
}
}
Any help would be greatly appreciated.
It's the first time I try this, so apologize if it's a trivial question...
Thank you all in advance.
My working library build.gradle is almost like yours. Except, it doesn't use the following:
plugins {
id 'com.android.library'
id 'maven-publish'
}
but the following:
apply plugin: 'com.android.library'
apply plugin: 'maven-publish'
And I'm using Java 8 for compileOptions block:
android {
...
...
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
And, lastly, without repositories in afterEvaluate:
afterEvaluate {
publishing {
...
// Remove the following commented line:
// repositories {
// mavenLocal()
// }
}
}
Then, to build and install the library to maven local, click gradle icon on the left menu of Android Studio. Then select projectName -> libraryName -> Run Configuration -> publishToMavenLocal.
UPDATE:
Here the complete build.gradle.
root build.gradle:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
mavenCentral()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:7.0.1'
}
}
repositories {
mavenCentral()
}
allprojects {
repositories {
jcenter()
mavenLocal()
mavenCentral()
maven { url "https://jitpack.io" }
google()
}
}
ext {
compileSdkVersion = 31
buildToolsVersion = '30.0.2'
minSdkVersion = 16
targetSdkVersion = 31
junitVersion = '4.13.2'
androidxAppcompatVersion = '1.4.1'
androidApplicationId = 'com.project.sample'
androidVersionCode = 1000
androidVersionName = "1.0.0"
androidAppName = 'Sample'
}
my library build.gradle (jcplayer library in root/jcplayer directory):
apply plugin: 'com.android.library'
apply plugin: 'maven-publish'
android {
compileSdkVersion rootProject.ext.compileSdkVersion
buildToolsVersion rootProject.ext.buildToolsVersion
defaultConfig {
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation "androidx.appcompat:appcompat:$androidxAppcompatVersion"
}
// Because the components are created only during the afterEvaluate phase, you must
// configure your publications using the afterEvaluate() lifecycle method.
afterEvaluate {
publishing {
publications {
// Creates a Maven publication called "release".
jcplayer(MavenPublication) {
// Applies the component for the release build variant.
from components.release
// You can then customize attributes of the publication as shown below.
groupId = rootProject.ext.androidApplicationId
artifactId = 'jcplayer'
version = rootProject.ext.androidVersionName
}
}
}
}
Before I have submitted the issue
[ ] I have read an installation guide
[ ] I know that for an iOS I need to install pods because I've read the installation guide
[ ] I have read a linking guide and checked that everything is OK like in manual linking guide
[ ] I know that before using tipsi-stripe I need to set options for my app as described in usage guide
The problem
Error on Android when try to call function deviceSupportNativePay, the error shown as image below
https://user-images.githubusercontent.com/54148306/79314833-6cde0680-7f2c-11ea-888d-e1836c038f98.png
Because I'm using RN 0.61.5, first I'm not using manual link, and on iOS is working just fine, not for android though. Now I try manual link for android, but still same issue. Has been followed many issues on stackoverflow and github with no luck. Can confirm stripe object is not null because already initiated it with setOptions.
Environment
tipsi-stripe version: 7.2.0
Last tipsi-stripe version where the issue was not reproduced (if applicable):
iOS or Android: Android
OS version: any version
React-Native version: 0.61.5
(Android only) com.google.firebase:firebase-core version: 16.0.9
(Android only) com.google.android.gms:play-services-base version: 16.1.0
Related config
/app/build.gradle
apply plugin: "com.android.application"
apply plugin: "io.fabric"
import com.android.build.OutputFile
project.ext.react = [
entryFile: "index.js",
enableHermes: false, // clean and rebuild if changing,
bundleAssetName: "index.android.bundle",
bundleInAlpha: true,
bundleInBeta: true
]
apply from: "../../node_modules/react-native/react.gradle"
apply from: "../../node_modules/react-native-code-push/android/codepush.gradle"
def enableHermes = project.ext.react.get("enableHermes", false);
android {
compileSdkVersion rootProject.ext.compileSdkVersion
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
defaultConfig {
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
ndk {
abiFilters "armeabi-v7a", "x86"
}
missingDimensionStrategy 'react-native-camera', 'general'
multiDexEnabled true
renderscriptTargetApi 23
renderscriptSupportModeEnabled true
}
splits {
abi {
reset()
enable enableSeparateBuildPerCPUArchitecture
universalApk false // If true, also generate a universal APK
include "armeabi-v7a", "x86", "arm64-v8a", "x86_64"
}
}
signingConfigs {
release {
if (project.hasProperty('MYAPP_RELEASE_STORE_FILE')) {
storeFile file(MYAPP_RELEASE_STORE_FILE)
storePassword MYAPP_RELEASE_STORE_PASSWORD
keyAlias MYAPP_RELEASE_KEY_ALIAS
keyPassword MYAPP_RELEASE_KEY_PASSWORD
}
}
}
buildTypes {
// debug {
// signingConfig signingConfigs.debug
// }
release {
// Caution! In production, you need to generate your own keystore file.
// see https://facebook.github.io/react-native/docs/signed-apk-android.
signingConfig signingConfigs.release
minifyEnabled enableProguardInReleaseBuilds
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
}
}
// applicationVariants are e.g. debug, release
applicationVariants.all { variant ->
variant.outputs.each { output ->
// For each separate APK per architecture, set a unique version code as described here:
// https://developer.android.com/studio/build/configure-apk-splits.html
def versionCodes = ["armeabi-v7a": 1, "x86": 2, "arm64-v8a": 3, "x86_64": 4]
def abi = output.getFilter(OutputFile.ABI)
if (abi != null) { // null for the universal-debug, universal-release variants
output.versionCodeOverride =
versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
}
}
}
dexOptions {
jumboMode true
preDexLibraries = false
// javaMaxHeapSize "4g"
}
configurations.all {
resolutionStrategy {
force 'com.android.support:design:28.0.0'
force 'com.android.support:support-v4:28.0.0'
// force 'com.google.android.gms:play-services-base:16.1.0'
// force 'com.android.support:appcompat-v7:28.0.0'
}
}
}
dependencies {
implementation (project(':tipsi-stripe')){
exclude group: 'com.google.android.gms'
exclude group: 'com.google.firebase'
}
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation "com.android.support:support-v4:27.1.0"
implementation "com.android.support:design:27.1.0"
implementation "com.android.support:appcompat-v7:27.1.0"
implementation "com.facebook.react:react-native:+" // From node_modules
// fbsdk
implementation 'com.facebook.android:facebook-android-sdk:[5,6)'
implementation project(':react-native-firebase')
// firebase
implementation "com.google.android.gms:play-services-base:16.1.0"
implementation "com.google.firebase:firebase-core:16.0.9"
// firebase messaging
implementation "com.google.firebase:firebase-messaging:18.0.0"
implementation 'me.leolin:ShortcutBadger:1.1.21#aar' // <-- Add this line if you wish to use badge on Android
// firebase crashlytic
implementation('com.crashlytics.sdk.android:crashlytics:2.9.9#aar') {
transitive = true
}
if (enableHermes) {
def hermesPath = "../../node_modules/hermes-engine/android/";
debugImplementation files(hermesPath + "hermes-debug.aar")
releaseImplementation files(hermesPath + "hermes-release.aar")
} else {
implementation jscFlavor
}
}
// Run this once to be able to run the application with BUCK
// puts all compile dependencies into folder libs for BUCK to use
task copyDownloadableDepsToLibs(type: Copy) {
from configurations.compile
into 'libs'
}
apply from: file("../../node_modules/#react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)
apply plugin: 'com.google.gms.google-services'
android/build.gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext {
buildToolsVersion = "28.0.3"
minSdkVersion = 22
compileSdkVersion = 28
targetSdkVersion = 28
googlePlayServicesAuthVersion = "16.0.1"
}
repositories {
mavenCentral()
google()
jcenter()
maven {
url 'https://maven.fabric.io/public'
}
}
dependencies {
classpath("com.android.tools.build:gradle:3.5.3")
classpath("com.google.gms:google-services:4.3.3")
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
classpath 'io.fabric.tools:gradle:1.28.1'
}
}
allprojects {
repositories {
mavenLocal()
google()
jcenter()
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url("$rootDir/../node_modules/react-native/android")
}
maven {
// Android JSC is installed from npm
url("$rootDir/../node_modules/jsc-android/dist")
}
maven { url "https://www.jitpack.io" }
maven { url "https://maven.google.com" }
}
}
ext {
compileSdkVersion = 28
targetSdkVersion = 28
buildToolsVersion = "28.0.3"
supportLibVersion = "28.0.0"
googlePlayServicesVersion = "11.8.0"
androidMapsUtilsVersion = "0.5+"
}
MainApplication.java
import android.app.Application;
import android.content.Context;
import com.facebook.react.PackageList;
import com.facebook.react.ReactApplication;
import com.facebook.react.ReactNativeHost;
import com.facebook.react.ReactPackage;
import com.facebook.soloader.SoLoader;
import java.lang.reflect.InvocationTargetException;
import java.util.List;
// codepush
import com.microsoft.codepush.react.CodePush;
// firebase
import io.invertase.firebase.RNFirebasePackage;
import io.invertase.firebase.messaging.RNFirebaseMessagingPackage;
import io.invertase.firebase.analytics.RNFirebaseAnalyticsPackage;
import io.invertase.firebase.fabric.crashlytics.RNFirebaseCrashlyticsPackage;
import io.invertase.firebase.notifications.RNFirebaseNotificationsPackage;
// google sign-in
import co.apptailor.googlesignin.RNGoogleSigninPackage;
import com.gettipsi.stripe.StripeReactPackage;
import java.util.Arrays;
import java.util.List;
import android.content.Intent;
public class MainApplication extends Application implements ReactApplication {
private final ReactNativeHost mReactNativeHost =
new ReactNativeHost(this) {
#Override
public boolean getUseDeveloperSupport() {
return BuildConfig.DEBUG;
}
#Override
protected String getJSBundleFile() {
return CodePush.getJSBundleFile();
}
#Override
protected List<ReactPackage> getPackages() {
#SuppressWarnings("UnnecessaryLocalVariable")
List<ReactPackage> packages = new PackageList(this).getPackages();
// Packages that cannot be autolinked yet can be added manually here, for example:
// firebase
// packages.add(new RNFirebasePackage());
packages.add(new RNFirebaseMessagingPackage());
packages.add(new RNFirebaseAnalyticsPackage());
packages.add(new RNFirebaseNotificationsPackage());
packages.add(new StripeReactPackage());
return packages;
}
#Override
protected String getJSMainModuleName() {
return "index";
}
};
#Override
public ReactNativeHost getReactNativeHost() {
return mReactNativeHost;
}
#Override
public void onCreate() {
super.onCreate();
SoLoader.init(this, /* native exopackage */ false);
// initializeFlipper(this); // Remove this line if you don't want Flipper enabled
}
/**
* Loads Flipper in React Native templates.
*
* #param context
*/
private static void initializeFlipper(Context context) {
if (BuildConfig.DEBUG) {
try {
/*
We use reflection here to pick up the class that initializes Flipper,
since Flipper library is not available in release mode
*/
Class<?> aClass = Class.forName("com.facebook.flipper.ReactNativeFlipper");
aClass.getMethod("initializeFlipper", Context.class).invoke(null, context);
} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (NoSuchMethodException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
}
}
}
}
react-native.config.js
module.exports = {
dependencies: {
'tipsi-stripe': {
platforms: {
android: null,
},
},
},
};
settings.gradle
include ':tipsi-stripe'
project(':tipsi-stripe').projectDir = new File(rootProject.projectDir, '../node_modules/tipsi-stripe/android')
I have an problem
My gradle setting
build.gradle(Module:app)
apply plugin: 'com.android.application'
android {
compileSdkVersion 24
buildToolsVersion "24.0.0"
defaultConfig {
applicationId "hanium.project.androidapp_picturehawk"
minSdkVersion 19
targetSdkVersion 24
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
/*
* native build settings: taking default for almost everything
*/
ndk {
moduleName = 'hello-jni'
toolchain = 'clang'
CFlags.addAll(['-Wall'])
}
productFlavors {
// for detailed abiFilter descriptions, refer to "Supported ABIs" #
// https://developer.android.com/ndk/guides/abis.html#sa
create("arm") {
ndk.abiFilters.add("armeabi")
}
create("arm7") {`enter code here`
ndk.abiFilters.add("armeabi-v7a")
}
create("arm8") {
ndk.abiFilters.add("arm64-v8a")
}
create("x86") {
ndk.abiFilters.add("x86")
}
create("x86-64") {
ndk.abiFilters.add("x86_64")
}
create("mips") {
ndk.abiFilters.add("mips")
}
create("mips-64") {
ndk.abiFilters.add("mips64")
}
// To include all cpu architectures, leaves abiFilters empty
create("all")
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:24.1.1'
}
build.gradle(Project:~)
-------------------------------------------------------------
// 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:2.1.2'
classpath 'com.android.tools.build:gradle-experimental:0.7.2'
// 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
}
----------------------------------------------
but i have an error
Error:(24, 0) Gradle DSL method not found: 'ndk()'
Possible causes:<ul><li>The project 'AndroidApp_PictureHawk' may be using a version of Gradle that does not contain the method.`enter code here`
Open Gradle wrapper file</li><li>The build file may be missing a Gradle plugin.
Apply Gradle plugin</li>
what should I do??
please help me
Read your error message!
Possible causes:<ul><li>The project 'AndroidApp_PictureHawk' may be using a version of Gradle that does not contain the method.`enter code here`
Then look for and remove enter code here:
productFlavors {
// for detailed abiFilter descriptions, refer to "Supported ABIs" #
// https://developer.android.com/ndk/guides/abis.html#sa
create("arm") {
ndk.abiFilters.add("armeabi")
}
create("arm7") {`enter code here`
ndk.abiFilters.add("armeabi-v7a")
}
I have been experiencing this error for quite some days. I have searched and tried other solution prior to posting this question.
This is my build.gradle file
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "com.apps.myApps"
minSdkVersion 14
targetSdkVersion 22
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
multiDexEnabled true
}
}
dexOptions {
preDexLibraries = false
}
}
afterEvaluate {
tasks.matching {
it.name.startsWith('dex')
}.each { dx ->
if (dx.additionalParameters == null) {
dx.additionalParameters = []
}
dx.additionalParameters += '--multi-dex'
}
}
dependencies {
provided fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:multidex:1.0.0'
compile "com.android.support:support-v4:18.0.+"
compile 'com.google.android.gms:play-services:7.5.0'
compile 'com.squareup:otto:1.3.8'
compile 'org.bouncycastle:bcprov-jdk15on:1.49'
compile 'net.simonvt.menudrawer:menudrawer:3.0.+#aar'
compile files('libs/acssmc-1.1.1.jar')
compile files('libs/activation.jar')
compile files('libs/additionnal.jar')
compile files('libs/android-async-http-1.4.6.jar')
compile files('libs/android-query-full.0.26.7.jar')
compile files('libs/androidmarketapi-0.6.jar')
compile files('libs/emvswipeapi-android-2.3.0.jar')
compile files('libs/mail.jar')
compile files('libs/newrelic.android.jar')
compile files('libs/nineoldandroids-2.4.0.jar')
compile files('libs/ormlite-android-4.47.jar')
compile files('libs/ormlite-core-4.47.jar')
}
I have identified that
compile 'org.bouncycastle:bcprov-jdk15on:1.49'
is causing the non zero exit value 3.
After I comment it, the error is gone.
But this jdk is important and I cannot comment it.
Is there another workaround for this?
** EDIT **
Added Error message in hope to help solve issue.
UNEXPECTED TOP-LEVEL ERROR:
java.lang.OutOfMemoryError: GC overhead limit exceeded
at com.android.dx.ssa.SetFactory.makeLivenessSet(SetFactory.java:91)
at com.android.dx.ssa.SsaBasicBlock.addLiveOut(SsaBasicBlock.java:792)
at com.android.dx.ssa.back.LivenessAnalyzer.liveOutAtBlock(LivenessAnalyzer.java:199)
at com.android.dx.ssa.back.LivenessAnalyzer.handleTailRecursion(LivenessAnalyzer.java:141)
at com.android.dx.ssa.back.LivenessAnalyzer.run(LivenessAnalyzer.java:188)
at com.android.dx.ssa.back.LivenessAnalyzer.constructInterferenceGraph(LivenessAnalyzer.java:93)
at com.android.dx.ssa.back.SsaToRop.<init>(SsaToRop.java:82)
at com.android.dx.ssa.back.SsaToRop.convertToRopMethod(SsaToRop.java:69)
at com.android.dx.ssa.Optimizer.optimize(Optimizer.java:101)
at com.android.dx.ssa.Optimizer.optimize(Optimizer.java:72)
at com.android.dx.dex.cf.CfTranslator.processMethods(CfTranslator.java:297)
at com.android.dx.dex.cf.CfTranslator.translate0(CfTranslator.java:137)
at com.android.dx.dex.cf.CfTranslator.translate(CfTranslator.java:93)
at com.android.dx.command.dexer.Main.processClass(Main.java:729)
at com.android.dx.command.dexer.Main.processFileBytes(Main.java:673)
at com.android.dx.command.dexer.Main.access$300(Main.java:83)
at com.android.dx.command.dexer.Main$1.processFileBytes(Main.java:602)
at com.android.dx.cf.direct.ClassPathOpener.processArchive(ClassPathOpener.java:284)
at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:166)
at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:144)
at com.android.dx.command.dexer.Main.processOne(Main.java:632)
at com.android.dx.command.dexer.Main.processAllFiles(Main.java:505)
at com.android.dx.command.dexer.Main.runMultiDex(Main.java:334)
at com.android.dx.command.dexer.Main.run(Main.java:244)
at com.android.dx.command.dexer.Main.main(Main.java:215)
at com.android.dx.command.Main.main(Main.java:106)
Error:Execution failed for task ':app:dexDebug'.
> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home/bin/java'' finished with non-zero exit value 3
Try to update your gradle file like this (add packagingOptions) :
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
...
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
}
}
I have used your entire build.gradle file without any error. My envrionment:
Android Studio 1.3.1
Inside build.gradle (in project folder):
dependencies {
classpath 'com.android.tools.build:gradle:1.3.0'
-MainActivity.java:
package com.example.testgradle;
import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.view.Menu;
import android.view.MenuItem;
public class MainActivity extends ActionBarActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
#Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_main, menu);
return true;
}
#Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
//noinspection SimplifiableIfStatement
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
}
Update with "OutOfMemoryError: GC overhead limit exceeded", try
dexOptions{
incremental true
javaMaxHeapSize "4g"
}