android ART NoClassDefFoundError when deploying a multidex apk to fabric beta - java

I have a strange issue.
I have this kotlin piece of code that sorts a dictionary, inside my multidix mixed java-kotlin application. (code below)
when running the app on development phone (SAMSUNG s9) everything runs ok.
When deployed the app to Fabric's "beta", a big portion (50%) of the users are having crashes of type NoClassDefFoundError.
The affected phones include xioami's MI 5s and Red-mi phones and multiple types of onePlus phones
I tried to look at the output apk (via build -> Analyze APK) and made sure the class is, indeed, there. As you can see from - that the class is actually on the main "classes.dex" file.
Any help will be much appreciated!
log file:
... (custom logging from the app on initiation level)
09-09 13:04:31.667 17365-17365/com.example.orcam.basic_recognition_app
I/art: Rejecting re-init on previously-failed class java.lang.Class<com.example.orcam.logic_myme.ComputedData.ComputedPersonData$calculateMeetingsForPerson$2>
... (custom logging from the app on normal run level)
09-09 13:04:31.762 17365-17365/com.example.orcam.basic_recognition_app
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.orcam.basic_recognition_app, PID: 17365
java.lang.NoClassDefFoundError: com.example.orcam.logic_myme.ComputedData.ComputedPersonData$calculateMeetingsForPerson$2
at com.example.orcam.logic_myme.ComputedData.ComputedPersonData.calculateMeetingsForPerson(ComputedPersonData.kt:45)
at com.example.orcam.logic_myme.ComputedData.ComputedData.calculate(ComputedData.kt:7)
at com.example.orcam.logic_myme.db.DBManager$init$2.onDbInitAndReady(DBManager.kt:79)
at com.example.lib_sync.sync.SyncManager2.(SyncManager2.java:63)
at com.example.orcam.logic_myme.db.DBManager.init(DBManager.kt:76)
at com.example.orcam.basic_recognition_app.LogicManager.init(LogicManager.java:58)
at com.example.orcam.basic_recognition_app.MyMeApplication.initManagers(MyMeApplication.kt:31)
at com.example.orcam.basic_recognition_app.MyMeApplication.onCreate(MyMeApplication.kt:13)
at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1014)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4782)
at android.app.ActivityThread.access$1700(ActivityThread.java:153)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1445)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:5544)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:739)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:629) 09-09
13:04:31.763 17365-17365/com.example.orcam.basic_recognition_app
E/MQSEventManagerDelegate: failed to get MQSService.
build.gradle file:
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
google()
}
dependencies {
classpath 'io.fabric.tools:gradle:1.+'
}
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
repositories {
maven { url 'https://maven.fabric.io/public' }
google()
}
android {
compileSdkVersion 27
buildToolsVersion "27.0.3"
defaultConfig {
applicationId "com.example.orcam.basic_recognition_app"
minSdkVersion 21
targetSdkVersion 27
versionCode 29
versionName "5.0.9"
}
buildTypes {
debug {
applicationIdSuffix ".debug"
}
beta {
initWith debug
applicationIdSuffix ""
}
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
pickFirst 'META-INF/LICENSE'
pickFirst 'META-INF/DEPENDENCIES'
pickFirst 'META-INF/ASL-2.0.txt'
pickFirst 'META-INF/LGPL-3.0.txt'
exclude 'META-INF/main.kotlin_module'
}
dexOptions {
preDexLibraries = false
}
}
ext {
supportLibVersion = '27.1.1'
}
dependencies {
/* ... a lot of dependencies ... */
// multi dex
implementation 'com.android.support:multidex:1.0.3'
// kotlin
compile "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}
kapt {
generateStubs = true
}
ComputedPersonData.kt file (simplified version with only the "bad" function):
class ComputedPersonData() {
var meetingsByPerson = mapOf<String, ArrayList<String>>()
fun calculateMeetingsForPerson() {
val faces: Map<String: Face?> = getFaces()
val faceToContact: Map<String: String?> = getMapping()
val peopleWithFaces = mutableMapOf<String, ArrayList<Face>>()
faces.values.forEach {
if (it != null) {
val personId = faceToContact[it.imageId] ?: ""
val list = peopleWithFaces[personId] ?: run {
peopleWithFaces[personId] = arrayListOf(it)
return#forEach
}
list.add(it)
}
}
val dictSorted = mutableMapOf<String, ArrayList<Face>>()
peopleWithFaces.forEach { id, item ->
dictSorted[id] = ArrayList(item.sortedBy { it.timestamp })
}
// the "dictSorted.mapValues{}" generates the "bad" $2 class
val dictFaceToString: Map<String, ArrayList<String>> = dictSorted.mapValues {
ArrayList(it.value.map {
it.id
}
)
}
this.meetingsByPerson = dictFaceToString
}
}
application class:
class MyApplication : MultiDexApplication()

well, after MONTHS of investigation apparently the bad lines were -
peopleWithFaces.forEach { id, item ->
dictSorted[id] = ArrayList(item.sortedBy { it.timestamp })
}
There was an issue with old android-OS (6.0.0 specific) and kotlin's decoupled for-each.
Once the problem found, the solution was easy. All we needed to do was to re-write this fun like that:
peopleWithFaces.forEach {
val id = it.key
val item = it.value
dictSorted[id] = ArrayList(item.sortedBy { it.timestamp })
}

Related

android studio: FAILURE: Build failed with an exception

I am trying to build a flutter app I get so many problems while building it and found a solutions for all of them but now I am stuck since the morning with this one:
> Task :firebase_auth:generateDebugRFile FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':firebase_auth:generateDebugRFile'.
> Could not resolve all files for configuration ':firebase_auth:debugCompileClasspath'.
> Could not find browser-1.0.0.aar (androidx.browser:browser:1.0.0).
Searched in the following locations:
https://dl.google.com/dl/android/maven2/androidx/browser/browser/1.0.0/browser-1.0.0.aar
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.7/userguide/command_line_interface.html#sec:command_line_warnings
BUILD FAILED in 37s
my project build.gradle:
buildscript {
ext.kotlin_version = '1.5.31'
repositories {
google()
jcenter()
maven {
url 'http://storage.googleapis.com/r8-releases/raw'
}
}
dependencies {
classpath 'com.android.tools:r8:2.1.75'
classpath 'com.google.gms:google-services:4.3.2'
classpath 'com.android.tools.build:gradle:4.1.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
allprojects {
repositories {
google()
jcenter()
}
}
rootProject.buildDir = '../build'
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
project.evaluationDependsOn(':app')
}
task clean(type: Delete) {
delete rootProject.buildDir
}
my app build.gradle:
buildscript {
repositories {
// ...
maven { url 'https://plugins.gradle.org/m2/' } // Gradle Plugin Portal
}
dependencies {
// ...
// OneSignal-Gradle-Plugin
classpath 'gradle.plugin.com.onesignal:onesignal-gradle-plugin:[0.12.6, 0.99.99]'
}
}
apply plugin: 'com.onesignal.androidsdk.onesignal-gradle-plugin'
def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
localPropertiesFile.withReader('UTF-8') { reader ->
localProperties.load(reader)
}
}
def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}
def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
flutterVersionCode = '1'
}
def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
flutterVersionName = '1.0'
}
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
def keystoreProperties = new Properties()
def keystorePropertiesFile = rootProject.file('key.properties')
if (keystorePropertiesFile.exists()) {
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
}
android {
compileSdkVersion 30
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
lintOptions {
disable 'InvalidPackage'
checkReleaseBuilds false
}
defaultConfig {
applicationId "com.inspireui.fluxstore"
minSdkVersion 20
targetSdkVersion 30
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
multiDexEnabled true
resConfigs "en"
manifestPlaceholders = [
onesignal_app_id: 'PUT_YOUR_ONESIGNAL_APP_ID_HERE',
// Project number pulled from dashboard, local value is ignored.
onesignal_google_project_number: 'REMOTE'
]
}
signingConfigs {
release {
keyAlias keystoreProperties['keyAlias']
keyPassword keystoreProperties['keyPassword']
storeFile file(keystoreProperties['storeFile'])
storePassword keystoreProperties['storePassword']
}
}
buildTypes {
release {
// Signing with the debug keys for now, so `flutter run --release` works.
signingConfig signingConfigs.release
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug {
signingConfig signingConfigs.release
}
}
}
flutter {
source '../..'
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
implementation 'com.android.support:multidex:1.0.3'
implementation 'androidx.browser:browser:1.3.0'
// For checking GMS availability.
implementation "com.google.android.gms:play-services-base:17.6.0"
// Fix duplicate exoplayer
implementation 'com.google.android.exoplayer:exoplayer:2.14.1'
}
googleServices { disableVersionCheck = true }
//Fix android-r issue
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
project.evaluationDependsOn(':app')
afterEvaluate {project ->
if (project.hasProperty("android") && project.property("android").compileSdkVersion.equals("android-R")) {
android {
compileSdkVersion 30
}
}
}
}
gradle.propertis:
org.gradle.jvmargs=-Xmx1536M
android.useAndroidX=true
android.enableJetifier=true
Solutions I tried:
invalidate cache and restart
flutter clean && flutter pub get
gradlew clean && gradlew build
delete the %USER%/.android and %USER%/.gradle and delete every thing related to android studio and reinstalled it
use a VPN ( tried 3 )
but unfortunatly, nothing helped me
for further info: I am building fluxstore app
I still think its a connection issue . is maven google available in your browser with no VPN ?
if no then here is a old solution of mine , on how to configure gradle to use you VPN properly . Because you need to tell gradle to send request over VPN using gradle.properties file .

Error while merging dex archives: Program type already present: org.apache.commons.io.Charsets

I'm trying to release APK in react native using ./gradlew bundleRelease I tried
Cleaning gradle
Adding multiDexEnabled true
FAILURE: Build failed with an exception.
What went wrong: Execution failed for task ':app:transformDexArchiveWithDexMergerForRelease'.
com.android.build.api.transform.TransformException: java.lang.RuntimeException: java.lang.RuntimeException:
com.android.builder.dexing.DexArchiveMergerException: Error while
merging dex archives: Program type already present:
org.apache.commons.io.Charsets Learn how to resolve the issue at
https://developer.android.com/studio/build/dependencies#duplicate_classes.
This is my build.gradle
buildscript {
ext {
buildToolsVersion = "28.0.3"
minSdkVersion = 23
compileSdkVersion = 28
targetSdkVersion = 28
supportLibVersion = "28.0.0"
googlePlayServicesVersion = "11+"
}
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.4.2'
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
}
}
allprojects {
repositories {
google()
mavenLocal()
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")
}
}
}
app/build.gradle
apply plugin: "com.android.application"
import com.android.build.OutputFile
project.ext.react = [
entryFile: "index.js",
enableHermes: false
]
apply from: '../../node_modules/react-native-unimodules/gradle.groovy'
apply from: "../../node_modules/react-native/react.gradle"
/**
* Set this to true to create two separate APKs instead of one:
* - An APK that only works on ARM devices
* - An APK that only works on x86 devices
* The advantage is the size of the APK is reduced by about 4MB.
* Upload all the APKs to the Play Store and people will download
* the correct one based on the CPU architecture of their device.
*/
def enableSeparateBuildPerCPUArchitecture = false
/**
* Run Proguard to shrink the Java bytecode in release builds.
*/
def enableProguardInReleaseBuilds = false
android {
compileSdkVersion rootProject.ext.compileSdkVersion
buildToolsVersion rootProject.ext.buildToolsVersion
defaultConfig {
applicationId "com.package..."
minSdkVersion 23
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 33
versionName "33.0"
multiDexEnabled 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_UPLOAD_STORE_FILE')) {
storeFile file(MYAPP_UPLOAD_STORE_FILE)
storePassword MYAPP_UPLOAD_STORE_PASSWORD
keyAlias MYAPP_UPLOAD_KEY_ALIAS
keyPassword MYAPP_UPLOAD_KEY_PASSWORD
}
}
}
buildTypes {
release {
minifyEnabled enableProguardInReleaseBuilds
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
signingConfig signingConfigs.release
}
}
// 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:
// http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits
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
}
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
packagingOptions {
pickFirst '**/libjsc.so'
pickFirst 'lib/x86/libc++_shared.so'
pickFirst 'lib/x86_64/libjsc.so'
pickFirst 'lib/arm64-v8a/libjsc.so'
pickFirst 'lib/arm64-v8a/libc++_shared.so'
pickFirst 'lib/x86_64/libc++_shared.so'
pickFirst 'lib/armeabi-v7a/libc++_shared.so'
}
}
def jscFlavor = 'org.webkit:android-jsc:+'
def enableHermes = project.ext.react.get("enableHermes", false);
dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}"
implementation "com.facebook.react:react-native:+" // From node_modules
implementation "com.google.android.gms:play-services-gcm:17.0.0"
implementation "com.google.android.gms:play-services-location:17.0.0"
//Add these lines
implementation "com.google.android.gms:play-services-base:17.3.0"
//implementation "com.google.firebase:firebase-core:15.0.2"
implementation "com.google.firebase:firebase-messaging:20.2.1"
implementation "com.google.firebase:firebase-inappmessaging:19.0.7"
// implementation "com.google.firebase:firebase-inappmessaging-display:19.0.7"
//implementation 'com.android.support:multidex:1.0.3'
//implementation project(':#mauron85_react-native-background-geolocation')
addUnimodulesDependencies()
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'
Still failing but on my emulator and android device its working fine. Does anyone have this problem too? I really appreciate any idea thanks.

Gradle debug Crashes with NullpointerException - Run works fine

Gradle crashes with a NullpointerException when trying to debug my app in Android Studio. It works fine just to Run the app. Android Studio 2.3.3.
Here's the gradle stacktrace:
java.lang.NullPointerException
at com.android.tools.idea.run.GradleApplicationIdProvider.getTestPackageName(GradleApplicationIdProvider.java:50)
at com.android.tools.idea.run.AndroidLaunchTasksProvider.getConnectDebuggerTask(AndroidLaunchTasksProvider.java:160)
at com.android.tools.idea.run.LaunchTaskRunner.run(LaunchTaskRunner.java:79)
at com.intellij.openapi.progress.impl.CoreProgressManager$TaskRunnable.run(CoreProgressManager.java:635)
at com.intellij.openapi.progress.impl.CoreProgressManager$3.run(CoreProgressManager.java:170)
at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:494)
at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:443)
at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:54)
at com.intellij.openapi.progress.impl.CoreProgressManager.runProcess(CoreProgressManager.java:155)
at com.intellij.openapi.progress.impl.ProgressManagerImpl$1.run(ProgressManagerImpl.java:128)
at com.intellij.openapi.application.impl.ApplicationImpl$2.run(ApplicationImpl.java:307)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Here's my build.gradle inside the app folder. Some more details: This is a project with the Cocos2d-x game engine and I'm trying to get Debug for native code to work. A simple test project does work, but my own project does not.
import java.util.regex.Pattern
import com.android.build.OutputFile
import org.apache.tools.ant.taskdefs.condition.Os
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
task('increaseVersionCode') << {
println 'Grade: Increasing Version Code...'
def buildFile = file("build.gradle")
def pattern = Pattern.compile("versionCode\\s+(\\d+)")
def manifestText = buildFile.getText()
def matcher = pattern.matcher(manifestText)
matcher.find()
def versionCode = Integer.parseInt(matcher.group(1))
def manifestContent = matcher.replaceAll("versionCode " + ++versionCode)
buildFile.write(manifestContent)
}
preBuild.dependsOn increaseVersionCode
task deleteGraphicsAssets(type: Delete) {
println 'Grade: Deleting unnecessary assets...'
delete "assets/1136p"
delete "assets/2048p"
}
preBuild.dependsOn deleteGraphicsAssets
android {
// Going higher means that we have to request to write to external storage (used for UUID): https://stackoverflow.com/questions/36084959/cant-create-a-directory-on-storage-emulated-0-on-emulator
// But GameAnalytics reqires 24, let's see if it still works this way
compileSdkVersion 22
buildToolsVersion '25.0.3' // should be 25 for newer version
defaultConfig {
applicationId "com.forestringgames.apps.towerduel"
minSdkVersion 15
// Going higher means that we have to request to write to external storage (used for UUID): https://stackoverflow.com/questions/36084959/cant-create-a-directory-on-storage-emulated-0-on-emulator
// But GameAnalytics reqires 24, let's see if it still works this way
targetSdkVersion PROP_TARGET_SDK_VERSION
versionCode 1607
versionName "1.0"
// multiDexEnabled true
externalNativeBuild {
ndkBuild {
if (!project.hasProperty("PROP_NDK_MODE") || PROP_NDK_MODE.compareTo('none') != 0) {
// skip the NDK Build step if PROP_NDK_MODE is none
targets 'cocos2dcpp'
arguments 'NDK_TOOLCHAIN_VERSION=4.9'
arguments 'APP_PLATFORM=android-' + PROP_TARGET_SDK_VERSION
def module_paths = [project.file("../../FRGEngine/cocos2d").absolutePath,
project.file("../../FRGEngine/cocos2d/cocos").absolutePath,
project.file("../../FRGEngine/cocos2d/external").absolutePath]
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
// should use '/'
module_paths = module_paths.collect { it.replaceAll('\\\\', '/') }
arguments 'NDK_MODULE_PATH=' + module_paths.join(";")
} else {
arguments 'NDK_MODULE_PATH=' + module_paths.join(':')
}
arguments '-j' + Runtime.runtime.availableProcessors()
abiFilters.addAll(PROP_APP_ABI.split(':').collect { it as String })
}
}
}
}
// only added for android debugging
externalNativeBuild {
ndkBuild {
if (!project.hasProperty("PROP_NDK_MODE") || PROP_NDK_MODE.compareTo('none') != 0) {
// skip the NDK Build step if PROP_NDK_MODE is none
path "jni/Android.mk"
}
}
}
sourceSets.main {
java.srcDir "src"
res.srcDir "res"
jniLibs.srcDir "libs"
manifest.srcFile "AndroidManifest.xml"
assets.srcDir "assets"
}
splits {
abi {
enable true
reset()
include 'armeabi-v7a'
//, 'armeabi', 'armeabi-v7a', 'x86' - what about arm64? Test it with Crashlytics
universalApk false //true
}
// density {
// enable true
// reset()
// include 'mdpi', 'hdpi', 'xhdpi', 'xxhdpi', 'xxxhdpi'
// compatibleScreens 'small', 'normal', 'large', 'xlarge'
//
// }
}
signingConfigs {
release {
if (project.hasProperty("RELEASE_STORE_FILE")) {
storeFile file(RELEASE_STORE_FILE)
storePassword RELEASE_STORE_PASSWORD
keyAlias RELEASE_KEY_ALIAS
keyPassword RELEASE_KEY_PASSWORD
}
}
}
buildTypes {
release {
minifyEnabled false // Warning: is this a good idea?
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
if (project.hasProperty("RELEASE_STORE_FILE")) {
signingConfig signingConfigs.release
}
externalNativeBuild {
ndkBuild {
arguments 'NDK_DEBUG=0'
}
}
}
debug {
// debuggable true
// jniDebuggable true
externalNativeBuild {
ndkBuild {
arguments 'NDK_DEBUG=1'
}
}
}
}
}
crashlytics {
enableNdk = true
androidNdkOut = 'obj'
androidNdkLibsOut = 'libs'
}
repositories {
mavenCentral()
}
dependencies {
// compile 'com.android.support:multidex:1.0.1'
compile fileTree(include: ['*.jar'], dir: 'libs')
compile project(':libcocos2dx')
// compile project(':BaseGameUtils')
// compile 'com.android.support:multidex:1.0.0'
compile 'com.facebook.android:facebook-android-sdk:4.8.0'
// compile 'com.google.android.gms:play-services-auth:9.0.0'
// integration guide (with latest version numbers: https://fabric.io/downloads/gradle)
// Crashlytics KitminifyEnabled
compile('com.crashlytics.sdk.android:crashlytics:2.6.8#aar') {
transitive = true
}
// NDK Kit
compile('com.crashlytics.sdk.android:crashlytics-ndk:1.1.6#aar') {
transitive = true
}
// compile('com.crashlytics.sdk.android:crashlytics:2.7.0-SNAPSHOT#aar') {
// transitive = true;
// }
//
// compile('com.crashlytics.sdk.android:crashlytics-ndk:1.2.0-SNAPSHOT:debug#aar') {
// transitive = true;
// }
compile 'net.bytebuddy:byte-buddy:1.7.3'
compile 'net.bytebuddy:byte-buddy-android:1.7.3'
// compile 'com.google.firebase:firebase-auth:11.0.1'
compile 'com.google.android.gms:play-services-auth:11.0.0'
compile 'com.google.android.gms:play-services-games:11.0.0'
compile 'com.google.firebase:firebase-invites:11.0.0'
compile 'com.google.firebase:firebase-messaging:11.0.0'
compile 'com.anjlab.android.iab.v3:library:1.0.+'
compile files('Frameworks/Fmod/prebuilt/android/fmod.jar')
// // use latest version instead version number: https://github.com/GameAnalytics/GA-SDK-ANDROID
// compile 'com.gameanalytics.sdk:gameanalytics-android:3.5.0'
compile fileTree(include: ['*.jar'], dir: 'Frameworks/Jars')
//
}
apply plugin: 'com.google.gms.google-services'
Here's the project-wide build.gradle file:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
// The Fabric Gradle plugin uses an open ended version to react
// quickly to Android tooling updates
//classpath 'io.fabric.tools:gradle:1.21.5' // version number: https://twittersdk.artifactoryonline.com/twittersdk/repo/io/fabric/tools/gradle/
classpath 'io.fabric.tools:gradle:1.+'
classpath 'com.google.gms:google-services:3.1.0'
}
}
allprojects {
repositories {
jcenter()
// FABRIC PRIVATE
// maven { url 'https://s3.amazonaws.com/fabric-artifacts-private/internal-snapshots' }
// FABRIC OFFICIAL
maven { url 'https://maven.fabric.io/public' }
// maven { url 'http://maven.gameanalytics.com/release' }
}
}
Edit: I also already tried this in this order:
Rebuild Project
Clean Project
Invalidate caches / Restart
In case you are using Gradle deamon. stop it by ./gradlew --stop and start over the steps from 1 to 3
Finally & destructively close Android Studio completely and delete .gradle directory ( it's hidden ) from the root of directory of your project and then launch Android Studio again.
Close all other Android Studio Instances
Restart OSX
Make sure your NDK path is properly configured on Project Structure (File > Project Structure > SDK Location > Android NDK Location). Click "OK" and try to sync again.

Android Parceler library: Unable to find generated Parcelable class

I'm trying to use the Parceler library in my Android Studio project.
The project has two modules, one is the app itself and the other is a personal android core library containing various helpers and generic entities.
However, I've added the Parceler dependency in my core library because I need it there too, so in the library build.gradle I've added the following lines:
compile "org.parceler:parceler-api:1.0.4"
apt "org.parceler:parceler:1.0.4"
I've not specified these lines inside the app build.gradle file because the dependency from Parceler will be imported automatically.
In my app I've defined an entity that have to be Parcelable and which implementation is:
#Parcel
public class Course {
public String name;
public Course() { /*Required empty bean constructor*/ }
public Course(String name) {
this.name = name;
}
}
But when I try to do
Course[] courses = ...retrieved from server...
Parcelable p = Parcels.wrap(courses);
The framework fires the following exception:
org.parceler.ParcelerRuntimeException: Unable to find generated Parcelable class for [Lit.bmsoftware.lotoapp.network.entity.Course;, verify that your class is configured properly and that the Parcelable class [Lit.bmsoftware.lotoapp.network.entity.Course;$$Parcelable is generated by Parceler.
I've already read various posts for that exception but I can't find a solution for my problem.
Could anyone help me?
Thanks in advance :)
EDIT: build.gradle file
plugins {
id "me.tatarka.retrolambda" version "3.2.4"
}
apply plugin: 'com.android.application'
apply plugin: 'com.neenbedankt.android-apt'
retrolambda {
jvmArgs '-noverify' // Issues: using Google Play Services causes retrolambda to fail
}
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "it.bmsoftware.lotoapp"
minSdkVersion 16
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
signingConfigs {
release {
storeFile file("*******.keystore")
storePassword "********"
keyAlias "*******"
keyPassword "*******"
}
}
buildTypes {
release {
//noinspection GroovyAssignabilityCheck
signingConfig signingConfigs.release
minifyEnabled false
shrinkResources false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
repositories {
mavenCentral()
mavenLocal()
}
dataBinding {
enabled = true
}
// Fixes bug in Data Binding library (Source folders generated at incorrect location)
// applicationVariants.all { variant ->
// def variantName = variant.name.capitalize()
// def inputDir = "${buildDir}/intermediates/classes/${variant.dirName}"
// def sourceDir = "${buildDir}/generated/source/dataBinding/${variant.dirName}"
// def copyTask = tasks.create(name: "dataBindingFix${variantName}", type: Copy) {
// from inputDir
// into sourceDir
// include '**/*.java'
// }
// tasks["generate${variantName}Sources"].dependsOn copyTask
// variant.addJavaSourceFoldersToModel new File(sourceDir)
// }
return true
}
ext {
supportLibVersion = '23.1.1' // variable that can be referenced to keep support libs consistent
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile project(':core')
compile "com.android.support:support-v13:${supportLibVersion}"
compile "com.android.support:design:${supportLibVersion}"
//compile "com.android.support:percent:${supportLibVersion}"
compile "com.android.support:recyclerview-v7:${supportLibVersion}"
compile "com.android.support:cardview-v7:${supportLibVersion}"
compile "org.parceler:parceler-api:1.0.4"
apt "org.parceler:parceler:1.0.4"
compile 'jp.wasabeef:recyclerview-animators:2.2.0'
}
The current release (1.0.4) does not support arrays of #Parcel annotated classes via the Parcels utility class. Instead, I'd suggest using a List:
List<Course> courses = ...retrieved from server...
Parcelable p = Parcels.wrap(courses);

Project Gradle sync keeps failing. (Gradle DSL method not found)

beginner android developer so not a lot of experience on how the gradle works, I've tried looking at other examples but I still cant get my problem. Basically, I've just downloaded one of the sample projects from google android developer examples, and cant successfully build the project. I keep getting: Gradle sync failed: Gradle DSL method not found: 'compile()'
The app gradle is:
apply plugin: 'com.android.application'
android {
enforceUniquePackageName = false
compileSdkVersion android_compile_version
buildToolsVersion android_version
defaultConfig {
minSdkVersion android_min_sdk_version
targetSdkVersion android_compile_version
versionCode 1
versionName "1.0"
}
lintOptions {
abortOnError false
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile "com.android.support:appcompat-v7:${appcompat_library_version}"
compile "com.android.support:support-v4:${support_library_version}"
compile project(':libraries:BaseGameUtils')
compile 'com.google.android.gms:play-services:4.3.23'
}
buildscript {
repositories {
jcenter()
}
}
and as for the project gradle:
// this is the parent build configuration for all the sample projects.
// for more information on gradle build files when used in a multi-project build, see
// http://gradle.org/docs/current/userguide/multi_project_builds.html
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.3.1'
}
}
// allprojects apply to every project
allprojects {
repositories {
jcenter()
}
ext {
android_compile_version = 23
android_version = '23.0.1'
android_min_sdk_version = 9
appcompat_library_version = '23.0.1'
support_library_version = '23.0.1'
gms_library_version = '8.1.0'
}
}

Categories

Resources