Realm android, RealmTransformer doesn't seem to be applied - java

i'm newbie.
I use:
Android studio 2.2.3
Gradle: 2.14.1
Realm-plugin: "classpath "io.realm:realm-gradle-plugin:2.2.1""
But it throws an exception while I'm calling Realm.init(context); in the onCreate of my Activity.
Log:
12-14 16:40:51.096 3541-3541/? E/AndroidRuntime: FATAL EXCEPTION: main
Process: *.demo, PID: 3541
java.lang.ExceptionInInitializerError: RealmTransformer doesn't seem to be applied. Please update the project configuration to use the Realm Gradle plugin. See https://realm.io/news/android-installation-change/
at io.realm.RealmConfiguration.<clinit>(RealmConfiguration.java:77)
at io.realm.RealmConfiguration$Builder.initializeBuilder(RealmConfiguration.java:414)
at io.realm.RealmConfiguration$Builder.<init>(RealmConfiguration.java:402)
at io.realm.Realm.init(Realm.java:188)
at *.demo.MainActivity.onCreate(MainActivity.java:21)
at android.app.Activity.performCreate(Activity.java:6237)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
at android.app.ActivityThread.-wrap11(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
My Class:
import io.realm.Realm;
public class MainActivity extends AppCompatActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Realm.init(this); //crashing line
}
}
Build.gradle module level:
apply plugin: 'com.android.application'
apply plugin: 'realm-android'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "*.demo"
minSdkVersion 10
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
jackOptions {
enabled true
}
// Enabling multidex support.
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
//proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
targetCompatibility 1.8
sourceCompatibility 1.8
}
}
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:25.1.0'
compile 'com.android.support:design:25.1.0'
compile 'com.android.support:multidex:1.0.1'
compile 'com.github.pwittchen:reactivenetwork:0.7.0'
testCompile 'junit:junit:4.12'
}
thanks in advance for help.

Jack doesn't work with the Transform API in Gradle.
As a result, the Realm-Transformer, which relies on the Transform API, cannot be used with Jack.
Use Retrolambda instead of Jack for Java 8 feature support.

You need to add this to the your d build.gradle file. :
repositories {
jcenter()
}
dependencies {
classpath "io.realm:realm-gradle-plugin:2.2.1"
}
Then do:
Once these two changes are made, simply refresh your gradle dependencies. If you are upgrading from a version prior to v0.88 you may also need to clean your gradle project (./gradlew clean) to remove any lingering previous installations.
Instructions can be found here, on the Realm website.

Related

Kotlin Class.forName fails for Mysql connector/j driver with NoSuchMethodError

I've added the my Connector/j 8.0 mysql-connector-java-8.0.16.jar file to my libs folder and added an entry in my app module build.gradle file.
But I get a java.lang.NoSuchMethodError exception when i try to Class.forName("com.mysql.cj.jdbc.Driver").newInstance() which is below:
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.testmate.hscmate, PID: 10196
java.lang.NoSuchMethodError: No static method metafactory(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/MethodType;Ljava/lang/invoke/MethodType;Ljava/lang/invoke/MethodHandle;Ljava/lang/invoke/MethodType;)Ljava/lang/invoke/CallSite; in class Ljava/lang/invoke/LambdaMetafactory; or its super classes (declaration of 'java.lang.invoke.LambdaMetafactory' appears in /apex/com.android.runtime/javalib/core-oj.jar)
at com.mysql.cj.jdbc.AbandonedConnectionCleanupThread.<clinit>(AbandonedConnectionCleanupThread.java:58)
at java.lang.Class.classForName(Native Method)
at java.lang.Class.forName(Class.java:454)
at java.lang.Class.forName(Class.java:379)
at com.mysql.cj.jdbc.NonRegisteringDriver.<clinit>(NonRegisteringDriver.java:99)
at java.lang.Class.classForName(Native Method)
at java.lang.Class.forName(Class.java:454)
at java.lang.Class.forName(Class.java:379)
at com.testmate.hscmate.MainActivity$onNavigationItemSelectedListener$1.onNavigationItemSelected(MainActivity.kt:24)
at com.google.android.material.bottomnavigation.BottomNavigationView$1.onMenuItemSelected(BottomNavigationView.java:204)
at androidx.appcompat.view.menu.MenuBuilder.dispatchMenuItemSelected(MenuBuilder.java:840)
at androidx.appcompat.view.menu.MenuItemImpl.invoke(MenuItemImpl.java:158)
at androidx.appcompat.view.menu.MenuBuilder.performItemAction(MenuBuilder.java:991)
at com.google.android.material.bottomnavigation.BottomNavigationMenuView$1.onClick(BottomNavigationMenuView.java:115)
at android.view.View.performClick(View.java:7125)
at android.view.View.performClickInternal(View.java:7102)
at android.view.View.access$3400(View.java:801)
at android.view.View$PerformClick.run(View.java:27301)
at android.os.Handler.handleCallback(Handler.java:883)
at android.os.Handler.dispatchMessage(Handler.java:100)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7319)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:934)
here is my build.gradle:
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion 29
buildToolsVersion "29.0.0"
defaultConfig {
applicationId "com.testmate.hscmate"
minSdkVersion 26
targetSdkVersion 29
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'androidx.core:core-ktx:1.0.2'
implementation 'com.google.android.material:material:1.0.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
implementation files('libs/mysql-connector-java-8.0.16.jar')
}
As far as I can tell, kotlin is finding the .jar, because otherwise it would be a ClassNotFoundException but it seems my SDK or JRE is missing this "static method metafactory" or something.
Connector/j 8.0 requires java 1.8.x which I believe I'm running with my compileSdkVersion and targetSdkVersion. I tried downloading sdkVersion 27 to build the app in a lower version but the app doesn't build.
I have no idea why my driver can't seem to find the things it needs.

Caused by: java.lang.NoSuchMethodError: No static method newFactory()

I'm building an Android application and facing a no static method exception when trying to read the XLSX files.
Tried all possibilities like updating dependencies in app/build.gradle, but no avail.
Kindly help me to resolve this issue.
Exception causing line in code: XSSFWorkbook myWorkBook = new XSSFWorkbook(fis);
08-07 12:37:05.828 16406-16511/droidmentor.tabwithviewpager E/AndroidRuntime:
FATAL EXCEPTION: AsyncTask #1
Process: droidmentor.tabwithviewpager, PID: 16406
java.lang.RuntimeException: An error occurred while executing doInBackground()
at android.os.AsyncTask$3.done(AsyncTask.java:325)
at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:354)
at java.util.concurrent.FutureTask.setException(FutureTask.java:223)
at java.util.concurrent.FutureTask.run(FutureTask.java:242)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:243)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
at java.lang.Thread.run(Thread.java:761)
Caused by: java.lang.NoSuchMethodError: No static method newFactory()Ljavax/xml/stream/XMLEventFactory; in class Ljavax/xml/stream/XMLEventFactory; or its super classes (declaration of 'javax.xml.stream.XMLEventFactory' appears in /data/app/droidmentor.tabwithviewpager-2/split_lib_dependencies_apk.apk)
at org.apache.poi.openxml4j.opc.internal.marshallers.PackagePropertiesMarshaller.<clinit>(PackagePropertiesMarshaller.java:45)
at org.apache.poi.openxml4j.opc.OPCPackage.init(OPCPackage.java:161)
at org.apache.poi.openxml4j.opc.OPCPackage.<init>(OPCPackage.java:141)
at org.apache.poi.openxml4j.opc.Package.<init>(Package.java:37)
at org.apache.poi.openxml4j.opc.ZipPackage.<init>(ZipPackage.java:87)
at org.apache.poi.openxml4j.opc.OPCPackage.open(OPCPackage.java:272)
at org.apache.poi.util.PackageHelper.open(PackageHelper.java:37)
at org.apache.poi.xssf.usermodel.XSSFWorkbook.<init>(XSSFWorkbook.java:254)
at droidmentor.tabwithviewpager.Fragment.ChatFragment$LongOperation.readXLSX(ChatFragment.java:191)
at droidmentor.tabwithviewpager.Fragment.ChatFragment$LongOperation.doInBackground(ChatFragment.java:112)
at droidmentor.tabwithviewpager.Fragment.ChatFragment$LongOperation.doInBackground(ChatFragment.java:88)
at android.os.AsyncTask$2.call(AsyncTask.java:305)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:243)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
at java.lang.Thread.run(Thread.java:761)
I'm adding app.gradle file. The other codes are basic XLSX file reading using XSSF. When I tried to run this java snippet in Spring Suite Tool, it runs properly. However, When I integrate those java snippets into the Android app, it causing this runtime exception.
App.Gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion '27.0.3'
defaultConfig {
applicationId "droidmentor.tabwithviewpager"
minSdkVersion 15
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'),
'proguard-rules.pro'
}
}
}
apply plugin: 'android'
repositories {
mavenCentral()
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
//noinspection GradleCompatible
compile 'com.android.support:appcompat-v7:25.0.0'
//noinspection GradleCompatible
compile 'com.android.support:design:25.0.+'
compile 'org.apache.poi:poi:3.10-FINAL'
compile 'net.sourceforge.jexcelapi:jxl:2.6.12'
compile 'commons-io:commons-io:2.4'
compile 'org.apache.poi:poi:3.11-beta2'
compile 'org.apache.poi:poi-ooxml:3.11-beta2'
compile 'javax.inject:javax.inject:1'
compile 'javax.servlet:servlet-api:2.5'
compile 'javax.servlet.jsp:jsp-api:2.1'
compile 'javax.servlet:jstl:1.2'
compile 'junit:junit:4.7'
compile 'net.sf.opencsv:opencsv:2.3'
compile 'org.apache.poi:poi-ooxml:2.3'
compile 'org.apache.poi:poi-ooxml-schemas:3.8'
compile 'org.apache.xmlbeans:xmlbeans:2.3.0'
compile 'dom4j:dom4j:1.6.1'
}
Check if you are applying any obfuscation on your apk, if yes, you need to -keep those packages and classes so that they won't be stripped by proguard.

Have problems with run Android Studio

Thats is my result so, error run code..
Exception in thread "main" java.lang.ClassNotFoundException: pya.marlon.com.pruebas.ExampleRXJava
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:264)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:123)
Process finished with exit code 1
Working with some example RXJava maybe have problems with gradle code..
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.3"
defaultConfig {
applicationId "pya.marlon.com.pruebas"
minSdkVersion 19
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
jackOptions{
enabled true
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
sourceSets {
main {
java.srcDirs = ['src/main/java', 'src/main/java-gen', '../greendao/classes']
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile project(':greendao')
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support.constraint:constraint-layout:1.0.0-beta4'
compile 'com.android.support:recyclerview-v7:25.3.1'
compile 'com.android.support:cardview-v7:25.3.1'
compile 'com.jakewharton:butterknife:8.5.1'
compile 'com.github.bumptech.glide:glide:3.8.0'
compile 'de.greenrobot:greendao:1.3.7'
testCompile 'junit:junit:4.12'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.5.1'
compile 'com.android.support:design:25.3.1'
compile 'io.reactivex:rxjava:1.3.0'
}
whats problem with my Android Studio so version is 2.3.2
i working with two modules in my project
Please read the exception message properly, it is clearly showing that pya.marlon.com.pruebas.ExampleRXJava class not found, possibly you did not include the above class.
One very good tutorial on RxJava can be found here RxJava 2.0 - Tutorial
To use RxJava in Android add the following dependency to your build.gradle file.
compile 'io.reactivex.rxjava2:rxandroid:2.0.1'
compile 'io.reactivex.rxjava2:rxjava:2.0.8
and have a look at this Tutorial RXJava Android Article

Android Studio 2.3 update error on jdbc connector

my app has mysql-connector-java-5.1.34.jar in libs folder and it was working fine. Now after yesterday's update to android studio 2.3, I start getting error
Suppressed: java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
03-05 15:25:22.696 17274-17618/jss.smartapp W/System.err: at java.lang.Class.classForName(Native Method)
03-05 15:25:22.696 17274-17618/jss.smartapp W/System.err: at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
03-05 15:25:22.696 17274-17618/jss.smartapp W/System.err: at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
03-05 15:25:22.696 17274-17618/jss.smartapp W/System.err: at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
I tried to change MySQL connector with 6.0.5 the latest downloaded and try to compile, it is giving another error
Error:Error converting bytecode to dex:
Cause: Dex cannot parse version 52 byte code.
This is caused by library dependencies that have been compiled using Java 8 or above.
If you are using the 'java' gradle plugin in a library submodule add
targetCompatibility = '1.7'
sourceCompatibility = '1.7'
to that submodule's build.gradle file.
How to fix it. though I tried to find some information on above here
Android: Dex cannot parse version 52 byte code
but nothing worked for me, below is my updated gradle.
compileSdkVersion 25
buildToolsVersion '25.0.0'
useLibrary 'org.apache.http.legacy'
defaultConfig {
applicationId "jss.smartapp"
minSdkVersion 19
targetSdkVersion 25
versionCode 12
versionName "1.4"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
sourceCompatibility = 1.7
targetCompatibility = 1.7
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.SigningInfo
}
debug {
signingConfig signingConfigs.SigningInfo
}
}
productFlavors {
def BOOLEAN = "boolean"
def TRUE = "true"
def FALSE = "false"
def A_FIELD = "A_FIELD"
internal {
buildConfigField BOOLEAN, A_FIELD, FALSE
}
official {
buildConfigField BOOLEAN, A_FIELD, TRUE
}
}
packagingOptions {
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/NOTICE.txt'
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
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:25.2.0'
testCompile 'junit:junit:4.12'
compile('com.crashlytics.sdk.android:crashlytics:2.6.5#aar') {
transitive = true;
}
//For Instamojo.
compile 'com.instamojo:android-sdk:+'
compile 'com.squareup.retrofit:retrofit:2.0.0-beta2'
compile 'com.squareup.retrofit:converter-gson:2.0.0-beta2'
//Apache IO
compile files('libs/commons-io-2.5.jar')
compile 'com.android.support:design:25.2.0'
compile 'com.android.support:appcompat-v7:25.2.0'

FlowingDrawer Sample does not run

I tried to run the sample of this library :
https://github.com/mxn21/FlowingDrawer
it works fine with this outdated build.gradle :
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "com.mt.stackoverflow"
minSdkVersion 9
targetSdkVersion 22
versionCode 120
versionName "1.2.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.2.0'
compile 'com.android.support:recyclerview-v7:22.+'
compile 'com.android.support:design:22.2.1'
compile 'com.squareup.picasso:picasso:2.5.0'
compile 'com.android.support:cardview-v7:22.+'
compile 'com.nineoldandroids:library:2.4.0'
compile 'com.mxn.soul:flowingdrawer-core:1.2.2'
}
but it fails with this updated build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
defaultConfig {
applicationId "com.mt.stackoverflow"
minSdkVersion 9
targetSdkVersion 23
versionCode 120
versionName "1.2.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:23.3.0'
compile 'com.android.support:recyclerview-v7:23.3.0'
compile 'com.android.support:design:23.3.0'
compile 'com.squareup.picasso:picasso:2.5.0'
compile 'com.android.support:cardview-v7:23.3.0'
compile 'com.nineoldandroids:library:2.4.0'
compile 'com.mxn.soul:flowingdrawer-core:1.2.2'
}
FATAL EXCEPTION: main
Process: com.mt.stackoverflow, PID: 31453
java.lang.RuntimeException: Unable to start activity
ComponentInfo{com.mt.stackoverflow/com.mt.stackoverflow.MainActivity}:
java.lang.IllegalArgumentException: Target must not be null.
at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2416)
at
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
at android.app.ActivityThread.-wrap11(ActivityThread.java)
at
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5422)
at java.lang.reflect.Method.invoke(Native Method)
at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Caused by: java.lang.IllegalArgumentException: Target must not be
null.
at com.squareup.picasso.RequestCreator.into(RequestCreator.java:607)
at com.squareup.picasso.RequestCreator.into(RequestCreator.java:590)
at
com.mt.stackoverflow.MyMenuFragment.setupHeader(MyMenuFragment.java:44)
at
com.mt.stackoverflow.MyMenuFragment.onCreateView(MyMenuFragment.java:31)
at
android.support.v4.app.Fragment.performCreateView(Fragment.java:1974)
at
android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1067)
at
android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1252)
at
android.support.v4.app.BackStackRecord.run(BackStackRecord.java:742)
at
android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1617)
at
android.support.v4.app.FragmentController.execPendingActions(FragmentController.java:339)
at
android.support.v4.app.FragmentActivity.onStart(FragmentActivity.java:602)
at
android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1237)
at android.app.Activity.performStart(Activity.java:6268)
at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2379)
at
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476) 
at android.app.ActivityThread.-wrap11(ActivityThread.java) 
at
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:148) 
at android.app.ActivityThread.main(ActivityThread.java:5422) 
at java.lang.reflect.Method.invoke(Native Method) 
at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Any ideas how I can run the sample with the moste recent build.gradle dependencies ?
The project is trying to access the ImageView in the header of the NavigationView in fragment_menu.xml in a way that is not compatible with the newer version of the support library. You can find the details in this post.
The ImageView is used as the target in a Picasso call and since the ImageView can no longer be found it is null and that is the cause of the IllegalArgumentException: Target must not be null error.
To fix it open the class MyMenuFragment and replace onCreateView(...) with the following:
#Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_menu, container, false);
View header = ((NavigationView) view.findViewById(R.id.vNavigation)).getHeaderView(0);
ivMenuUserProfilePhoto = (ImageView) header.findViewById(R.id.ivMenuUserProfilePhoto);
setupHeader();
return setupReveal(view) ;
}
Basically you can no longer find ivMenuUserProfilePhoto directly from view. You first need to get the header view from the NavigationView and then find the ImageView using the header.

Categories