retrolambda
Backport of Java 8's lambda expressions to Java 7, 6 and 5
I have written a small set of minilibraries for my internal use. This is set is built using Maven. The libraries are targetted for "regular" Java, GWT and Android. Some of them are written in Java 8 because I hadn't any intention to run them on GWT or Android, thus the other libraries are written in old Java 6 to support these two. I have a plan of full migration of my libs to Java 8 (in terms of language features), and I succeeded to run Java 8 rewritten libraries on not yet released GWT 2.8.0. However, I cannot make the Java 8 rewritten libs to compile for Android applications. The issue is that Retrolambda (the retrolambda-maven-plugin
plugin) seems to be able to process the current Maven module classes only, and fully ignores the dependency classes. Thus, the android-maven-plugin
breaks the target application build with:
[INFO] UNEXPECTED TOP-LEVEL EXCEPTION:
[INFO] com.android.dx.cf.iface.ParseException: bad class file magic (cafebabe) or version (0034.0000)
[INFO] at com.android.dx.cf.direct.DirectClassFile.parse0(DirectClassFile.java:472)
[INFO] at com.android.dx.cf.direct.DirectClassFile.parse(DirectClassFile.java:406)
[INFO] at com.android.dx.cf.direct.DirectClassFile.parseToInterfacesIfNecessary(DirectClassFile.java:388)
[INFO] at com.android.dx.cf.direct.DirectClassFile.getMagic(DirectClassFile.java:251)
[INFO] at com.android.dx.command.dexer.Main.processClass(Main.java:665)
[INFO] at com.android.dx.command.dexer.Main.processFileBytes(Main.java:634)
[INFO] at com.android.dx.command.dexer.Main.access$600(Main.java:78)
[INFO] at com.android.dx.command.dexer.Main$1.processFileBytes(Main.java:572)
[INFO] at com.android.dx.cf.direct.ClassPathOpener.processArchive(ClassPathOpener.java:284)
[INFO] at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:166)
[INFO] at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:144)
[INFO] at com.android.dx.command.dexer.Main.processOne(Main.java:596)
[INFO] at com.android.dx.command.dexer.Main.processAllFiles(Main.java:498)
[INFO] at com.android.dx.command.dexer.Main.runMonoDex(Main.java:264)
[INFO] at com.android.dx.command.dexer.Main.run(Main.java:230)
[INFO] at com.android.dx.command.dexer.Main.main(Main.java:199)
[INFO] at com.android.dx.command.Main.main(Main.java:103)
[INFO] ...while parsing foo/bar/FooBar.class
The retrolambda-maven-plugin
is configured as follows:
<plugin>
<groupId>net.orfjackal.retrolambda</groupId>
<artifactId>retrolambda-maven-plugin</artifactId>
<version>2.0.2</version>
<executions>
<execution>
<phase>compile</phase>
<goals>
<goal>process-main</goal>
<goal>process-test</goal>
</goals>
</execution>
</executions>
<configuration>
<target>1.6</target>
<defaultMethods>true</defaultMethods>
</configuration>
</plugin>
Is it possible to configure the Retrolambda plugin to process the library classes as well so all dependencies? Or maybe I just could use another bytecode processing tool?
UPDATE #1
I think I'm wrong about the Retrolambda fail. Digging into it a little more, I've figured out that android-maven-plugin
can be blamed for it because it picks the not instrumented JAR files from the Maven repository directly, and not from the target
directory. Enabling verbose logging discovered this pseudo-code command invoked by the android-maven-plugin
:
$JAVA_HOME/jre/bin/java
-Xmx1024M
-jar "$ANDROID_HOME/sdk/build-tools/android-4.4/lib/dx.jar"
--dex
--output=$BUILD_DIRECTORY/classes.dex
$BUILD_DIRECTORY/classes
$M2_REPO/foo1/bar1/0.1-SNAPSHOT/bar1-0.1-SNAPSHOT.jar
$M2_REPO/foo2/bar2/0.1-SNAPSHOT/bar2-0.1-SNAPSHOT.jar
$M2_REPO/foo3/bar3/0.1-JAVA-8-SNAPSHOT/bar3-0.1-JAVA-8-SNAPSHOT.jar
My idea is executing the maven-dependency-plugin
plugin to obtain those three artifacts into the $BUILD_DIRECTORY/classes
directory to let the retrolambda-maven-plugin
instrument the dependencies. Let's say:
STEP 1: Copy the dependencies to the target directory
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<phase>process-classes</phase>
<goals>
<goal>unpack-dependencies</goal>
</goals>
<configuration>
<includeScope>runtime</includeScope>
<outputDirectory>${project.build.directory}/classes</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
STEP 2: Instrument the copied dependencies using Retrolambda
Invoke retrolambda-maven-plugin
STEP 3: Compile the DEX file
Invoke android-maven-plugin
excluding the dependencies that were copied to the target directory, because they are all supposed to be located in the target directory
But this fails too, because I can't find a way to exclude artifacts from being DEXed with the android-maven-plugin
.
How do I suppress the artifacts from being fetched from the repository where they are stored in non-instrumented state?
My plugins configuration:
- org.apache.maven.plugins:maven-dependency-plugin:2.10
- net.orfjackal.retrolambda:retrolambda-maven-plugin:2.0.2
- com.jayway.maven.plugins.android.generation2:android-maven-plugin:3.9.0-rc.3
Source: (StackOverflow)
My travis.yml file:
language: android
jdk: oraclejdk8
android:
components:
- build-tools-22.0.1
- android-22
- extra-android-m2repository
script:
- gradle build connectedCheck
It fails during app:compileRetrolambdaDebug
with error message Process 'command '/usr/lib/jvm/java-8-oracle/bin/java'' finished with non-zero exit value 1
.
Is it possible to run Retrolambda on Travis CI?
After adding --debug parameter, I got following information:
13:44:02.064 [INFO] [system.out] Error! Failed to transform some classes
13:44:02.073 [INFO] [system.out] java.lang.RuntimeException: java.lang.IllegalAccessException: no such method: cz.skaut.warehousemanager.fragment.ItemDetailFragment.lambda$onViewCreated$32(Bitmap)void/invokeSpecial
at net.orfjackal.retrolambda.lambdas.LambdaReifier.reifyLambdaClass(LambdaReifier.java:42)
at net.orfjackal.retrolambda.lambdas.BackportLambdaInvocations$InvokeDynamicInsnConverter.backportLambda(BackportLambdaInvocations.java:105)
at net.orfjackal.retrolambda.lambdas.BackportLambdaInvocations$InvokeDynamicInsnConverter.visitInvokeDynamicInsn(BackportLambdaInvocations.java:94)
at net.orfjackal.retrolambda.asm.ClassReader.readCode(ClassReader.java:1439)
at net.orfjackal.retrolambda.asm.ClassReader.readMethod(ClassReader.java:1017)
at net.orfjackal.retrolambda.asm.ClassReader.accept(ClassReader.java:693)
at net.orfjackal.retrolambda.asm.ClassReader.accept(ClassReader.java:506)
at net.orfjackal.retrolambda.Transformers.lambda$transform$4(Transformers.java:106)
at net.orfjackal.retrolambda.Transformers$$Lambda$2/1190900417.accept(Unknown Source)
at net.orfjackal.retrolambda.Transformers.transform(Transformers.java:120)
at net.orfjackal.retrolambda.Transformers.transform(Transformers.java:106)
at net.orfjackal.retrolambda.Transformers.backportClass(Transformers.java:46)
at net.orfjackal.retrolambda.Retrolambda.run(Retrolambda.java:72)
at net.orfjackal.retrolambda.Main.main(Main.java:26)
13:44:02.086 [INFO] [system.out] Caused by: java.lang.IllegalAccessException: no such method: cz.skaut.warehousemanager.fragment.ItemDetailFragment.lambda$onViewCreated$32(Bitmap)void/invokeSpecial
at java.lang.invoke.MemberName.makeAccessException(MemberName.java:872)
at java.lang.invoke.MemberName$Factory.resolveOrFail(MemberName.java:993)
at java.lang.invoke.MethodHandles$Lookup.resolveOrFail(MethodHandles.java:1379)
at java.lang.invoke.MethodHandles$Lookup.findSpecial(MethodHandles.java:997)
at net.orfjackal.retrolambda.lambdas.Types.toMethodHandle(Types.java:42)
at net.orfjackal.retrolambda.lambdas.Types.asmToJdkType(Types.java:19)
at net.orfjackal.retrolambda.lambdas.LambdaReifier.callBootstrapMethod(LambdaReifier.java:106)
at net.orfjackal.retrolambda.lambdas.LambdaReifier.reifyLambdaClass(LambdaReifier.java:37)
... 13 more
13:44:02.089 [INFO] [system.out] Caused by: java.lang.NoClassDefFoundError: android/support/v4/view/LayoutInflaterFactory
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:760)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:455)
at java.net.URLClassLoader.access$100(URLClassLoader.java:73)
at java.net.URLClassLoader$1.run(URLClassLoader.java:367)
at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:360)
at net.orfjackal.retrolambda.NonDelegatingClassLoader.loadClass(NonDelegatingClassLoader.java:25)
at java.lang.invoke.MethodHandleNatives.resolve(Native Method)
at java.lang.invoke.MemberName$Factory.resolve(MemberName.java:965)
at java.lang.invoke.MemberName$Factory.resolveOrFail(MemberName.java:990)
... 19 more
13:44:02.092 [INFO] [system.out] Caused by: java.lang.ClassNotFoundException: android.support.v4.view.LayoutInflaterFactory
at java.net.URLClassLoader$1.run(URLClassLoader.java:372)
at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:360)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at net.orfjackal.retrolambda.NonDelegatingClassLoader.loadClass(NonDelegatingClassLoader.java:27)
... 32 more
Similar error is reported here, so it may be Gradle-retrolambda plugin issue.
Source: (StackOverflow)
Is anyone using Retrolambda for a Google App Engine project? What does your pom.xml look like?
It's straightforward to compile for JDK8 and set up retrolambda's maven plugin. However, to deploy to GAE, Google's appengine-maven-plugin needs to be run under JDK7 otherwise it will compile JSP files into a format that breaks in production.
How can I use JDK8+retrolambda for compilation, but JDK7 for appengine:update?
Source: (StackOverflow)
I'm a rookie with OSX. Today I try to use RxJava and Retrolambda in Android Studio, Retrolambda needs gradle--retrolambda.
So I started config:
1.I pasted a little code to ~/.bash_profile to set the JAVA7_HOME and JAVA8_HOME
export JAVA7_HOME=/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home
export PATH=$JAVA_HOME/bin:$PATH
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export JAVA8_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home
export PATH=$JAVA_HOME/bin:$PATH
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
PATH="/Library/Frameworks/Python.framework/Versions/3.4/bin:${PATH}"
export PATH
It seems work fine , I check it use terminal
echo $JAVA8_HOME
/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home
echo $JAVA7_HOME
/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home
Then I following Others article
2.Edited Android Studio -> Preference -> Path Variables
Added "JAVA8_HOME" and "JAVA7_HOME" ,same as above
3.Edited build.gradle (Project)
dependencies {
classpath 'com.android.tools.build:gradle:1.3.0'
classpath 'me.tatarka:gradle-retrolambda:3.2.2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
4.Edited build.gradle(app)
apply plugin: 'com.android.application'
apply plugin: 'me.tatarka.retrolambda' #Added here!
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "com.example.ezioshiki.demoproject"
minSdkVersion 16
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
#Added here!
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
#Added here!
String java8 = getJavaVersion(8)
String java7 = getJavaVersion(7)
retrolambda {
jdk java8 //have tried with JAVA8_HOME
oldJdk java7 //have tried with JAVA6_HOME
javaVersion JavaVersion.VERSION_1_7 //have matched the above with VERSION_1_6
}
String getJavaVersion(Integer v) {
def sout = new StringBuffer()
def proc = "/usr/libexec/java_home -v 1.$v".execute()
proc.consumeProcessOutput(sout, new StringBuffer())
proc.waitForOrKill(1000)
return sout.toString().replace("\n", "").replace("\r", "")
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:23.0.1'
compile 'com.jakewharton:butterknife:7.0.1'
compile 'com.android.support:recyclerview-v7:23.0.1'
compile 'io.reactivex:rxjava:1.0.14'
compile 'net.orfjackal.retrolambda:retrolambda:2.0.6'
compile 'me.tatarka:gradle-retrolambda:3.2.2'
}
I followed https://github.com/evant/gradle-retrolambda/issues/61 , because gradle-retrolambda official suggestion cannot find Java8, and this issues worked.
But it gave me :
Information:Gradle tasks [:app:assembleDebug]
:app:preBuild UP-TO-DATE
:app:preDebugBuild UP-TO-DATE
:app:checkDebugManifest
:app:preReleaseBuild UP-TO-DATE
:app:prepareComAndroidSupportAppcompatV72301Library UP-TO-DATE
:app:prepareComAndroidSupportRecyclerviewV72301Library UP-TO-DATE
:app:prepareComAndroidSupportSupportV42301Library UP-TO-DATE
:app:prepareDebugDependencies
:app:compileDebugAidl UP-TO-DATE
:app:compileDebugRenderscript UP-TO-DATE
:app:generateDebugBuildConfig UP-TO-DATE
:app:generateDebugAssets UP-TO-DATE
:app:mergeDebugAssets UP-TO-DATE
:app:generateDebugResValues UP-TO-DATE
:app:generateDebugResources UP-TO-DATE
:app:mergeDebugResources UP-TO-DATE
:app:processDebugManifest UP-TO-DATE
:app:processDebugResources UP-TO-DATE
:app:generateDebugSources UP-TO-DATE
:app:processDebugJavaRes UP-TO-DATE
:app:compileDebugJavaWithJavac UP-TO-DATE
:app:compileRetrolambdaDebug
:app:compileDebugNdk UP-TO-DATE
:app:compileDebugSources UP-TO-DATE
:app:preDexDebug
UNEXPECTED TOP-LEVEL EXCEPTION:
java.lang.RuntimeException: Exception parsing classes
at com.android.dx.command.dexer.Main.processClass(Main.java:752)
at com.android.dx.command.dexer.Main.processFileBytes(Main.java:718)
at com.android.dx.command.dexer.Main.access$1200(Main.java:85)
at com.android.dx.command.dexer.Main$FileBytesConsumer.processFileBytes(Main.java:1645)
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:672)
at com.android.dx.command.dexer.Main.processAllFiles(Main.java:574)
at com.android.dx.command.dexer.Main.runMonoDex(Main.java:311)
at com.android.dx.command.dexer.Main.run(Main.java:277)
at com.android.dx.command.dexer.Main.main(Main.java:245)
at com.android.dx.command.Main.main(Main.java:106)
Caused by: com.android.dx.cf.iface.ParseException: bad class file magic (cafebabe) or version (0034.0000)
at com.android.dx.cf.direct.DirectClassFile.parse0(DirectClassFile.java:472)
at com.android.dx.cf.direct.DirectClassFile.parse(DirectClassFile.java:406)
at com.android.dx.cf.direct.DirectClassFile.parseToInterfacesIfNecessary(DirectClassFile.java:388)
at com.android.dx.cf.direct.DirectClassFile.getMagic(DirectClassFile.java:251)
at com.android.dx.command.dexer.Main.parseClass(Main.java:764)
at com.android.dx.command.dexer.Main.access$1500(Main.java:85)
at com.android.dx.command.dexer.Main$ClassParserTask.call(Main.java:1684)
at com.android.dx.command.dexer.Main.processClass(Main.java:749)
... 12 more
1 error; aborting
Error:Execution failed for task ':app:preDexDebug'.
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 1
Information:BUILD FAILED
Information:Total time: 2.143 secs
Information:1 error
Information:0 warnings
Information:See complete output in console
I can't handle this. Anyone could help me ? Very very thank you :)
Source: (StackOverflow)
I have done android pretty much but new to java 8.
I have made a BehaviourSubject< Map< String,String>>.
I have put an observable on it. From presenter class I am setting BehaviourSbuject as observable and as soon as onClick is made the onNext is calling of the same. But it is throwing rx.exceptions.OnErrorNotImplementedException.
I am not getting why it is throwing this error as I have reffered to this http://reactivex.io/RxJava/javadoc/index.html?rx/exceptions/OnErrorNotImplementedException.html but according to this I am only made on onNext call to observable still getting this error.
MainScreenView is an interface which is implemented by MainScreenFragment.
Presenter class
public class MainScreenPresenter {
public MainScreenPresenter(MainScreenView view, MainScreenModel model) {
Log.i("MainScreenPresenter", "default constructor");
view.addPlace().subscribe(place -> model.place(place));
}
}
MainScreenFragment class
public class MainScreenFragment extends Fragment implements MainScreenView, View.OnClickListener {
ArrayList<Place> places;
View mainScreenRootFragment;
Button addPlace;
TextView venueDate;
Place newPlace;
BehaviorSubject<Map<String, String>> placeAdded = BehaviorSubject.create();
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
mainScreenRootFragment = inflater.inflate(R.layout.main_screen_fragment, container);
Log.i("MainScreenFragment", "onCreateView");
setRetainInstance(true);
return mainScreenRootFragment;
}
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
Log.i("MainScreenFragment", "onViewCreated");
initializeViews(view);
setEventsForViews();
}
private void setEventsForViews() {
addPlace.setOnClickListener(this);
}
private void initializeViews(View view) {
addPlace = (Button) view.findViewById(R.id.add_place);
venueDate = (TextView) view.findViewById(R.id.venue_date);
places = new ArrayList<>();
}
@Override
public Observable<Map<String, String>> addPlace() {
Log.i("MainScreenFragment", "addPlace");
return placeAdded.asObservable();
}
@Override
public void onClick(View v) {
if (v.getId() == R.id.add_place) {
Log.i("MainScreenFragment", "add_place button clicked");
placeData();
Log.i("MainScreenFragment", "after onNext()");
} else if (v.getId() == R.id.rv) {
}
}
private void placeData() {
Log.i("MainScreenFragment", "data is mapping in placeData()");
Map<String, String> map = new HashMap<>();
map.put("placeName", "Lonavala");
map.put("placeDate", "20/5/2015");
placeAdded.onNext(map);
}
}
Errors
07-10 10:14:25.414 2754-2754/com.example.vikky.hisab W/dalvikvm﹕ threadid=1: thread exiting with uncaught exception (group=0x41703d58)
07-10 10:14:25.424 2754-2754/com.example.vikky.hisab E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: com.example.vikky.hisab, PID: 2754
rx.exceptions.OnErrorNotImplementedException
at rx.Observable$31.onError(Observable.java:7204)
at rx.observers.SafeSubscriber._onError(SafeSubscriber.java:127)
at rx.observers.SafeSubscriber.onError(SafeSubscriber.java:96)
at rx.observers.SafeSubscriber.onNext(SafeSubscriber.java:111)
at rx.internal.operators.NotificationLite.accept(NotificationLite.java:150)
at rx.subjects.SubjectSubscriptionManager$SubjectObserver.emitNext(SubjectSubscriptionManager.java:254)
at rx.subjects.BehaviorSubject.onNext(BehaviorSubject.java:166)
at com.example.vikky.hisab.MainScreenFragment.placeData(MainScreenFragment.java:115)
at com.example.vikky.hisab.MainScreenFragment.onClick(MainScreenFragment.java:100)
at android.view.View.performClick(View.java:4444)
at android.view.View$PerformClick.run(View.java:18440)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5050)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:806)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:622)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.NullPointerException
at com.example.vikky.hisab.MainScreenPresenter.lambda$new$5(MainScreenPresenter.java:11)
at com.example.vikky.hisab.MainScreenPresenter.access$lambda$0(MainScreenPresenter.java)
at com.example.vikky.hisab.MainScreenPresenter$$Lambda$1.call(Unknown Source)
at rx.Observable$31.onNext(Observable.java:7209)
at rx.observers.SafeSubscriber.onNext(SafeSubscriber.java:104)
Thanks in advance
Source: (StackOverflow)
Having big problems trying to get retrolambda working in my project. There are plenty of sex issues and solutions out there but I haven't found any that doesn't resort to adding the multiDexEnabled
flag to the grade file.
I am getting the following error.
Error:Execution failed for task ':mobile:dexDebug'.
com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/Library/Java/JavaVirtualMachines/jdk1.8.0_51.jdk/Contents/Home/bin/java'' finished with non-zero exit value 2
To fix this I can add the multiDexEnabled true
and this works however it also adds 1 minute onto my build time and this is unacceptable for development.
Is there another way or should I just not use Retrolambda?
EDIT Added build.grade code.
apply plugin: 'com.android.application'
apply plugin: 'me.tatarka.retrolambda'
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "com.myapplication"
multiDexEnabled true
minSdkVersion 11
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
buildscript {
repositories {
mavenCentral()
jcenter()
}
dependencies {
classpath 'me.tatarka:gradle-retrolambda:3.2.0'
}
}
repositories {
mavenCentral()
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.google.android.gms:play-services-maps:7.5.0'
compile 'com.google.android.gms:play-services-wearable:7.5.0'
compile 'com.google.android.gms:play-services-location:7.5.0'
compile 'com.android.support:appcompat-v7:22.2.1'
compile 'com.android.support:support-v4:22.2.1'
compile 'com.android.support:design:22.2.1'
compile 'com.android.support:cardview-v7:22.2.1'
compile 'com.android.support:recyclerview-v7:22.2.1'
compile 'com.android.support:support-annotations:22.2.1'
compile 'com.jakewharton:butterknife:7.0.1'
compile 'joda-time:joda-time:2.7'
/*Graphs*/
compile 'com.androidplot:androidplot-core:0.6.1'
/*Parse*/
compile project(':ParseLoginUI')
/*Images*/
compile 'com.squareup.picasso:picasso:2.3.3'
compile 'com.makeramen:roundedimageview:2.1.0' // https://github.com/vinc3m1/RoundedImageView
compile 'io.reactivex:rxandroid:0.25.0'
}
EDIT After changing my JDK Version to 1.7 Error
Error:Execution failed for task ':activity-manager:compileDebugJava'.
When running gradle with java 5, 6 or 7, you must set the path to jdk8, either with property retrolambda.jdk or environment variable
JAVA8_HOME
So in my .bash_profile I set the environment variables like so:
export JAVA_HOME=$(/usr/libexec/java_home)
export JAVA8_HOME=$(/usr/libexec/java_home)
export JAVA7_HOME=$(/usr/libexec/java_home -v 1.7)
Now when I do the following in termainal echo JAVA8_HOME
it comes up with the correct path however my Gradle still doesn't pick it up. I am testing it like so in my grade file.
println("***************** ---------- *******************")
println("JAVA_HOME: " + System.getenv("JAVA_HOME"))
println("JAVA7_HOME: " + System.getenv("JAVA7_HOME"))
println("JAVA8_HOME: " + System.getenv("JAVA8_HOME"))
println("***************** ---------- *******************")
The result is null for all of these outputs.
EDIT I have also overridden the retrolambda tag with the following.
retrolambda {
jdk "/Library/Java/JavaVirtualMachines/jdk1.8.0_51.jdk/Contents/Home"
oldJdk "/Library/Java/JavaVirtualMachines/jdk1.7.0_75.jdk/Contents/Home"
javaVersion JavaVersion.VERSION_1_7
}
I then go back to getting the original exception with the "finished with non-zero exit value 2" but now with the JDK version set in the project settings.
Error:Execution failed for task ':mobile:dexDebug'.
com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command
'/Library/Java/JavaVirtualMachines/jdk1.7.0_75.jdk/Contents/Home/bin/java''
finished with non-zero exit value 2
Source: (StackOverflow)
Following the guide- Setting up the AWS Device Farm Gradle Plugin, I set up my application and ran ./gradlew devicefarmUpload
but I ran into a lot of errors. On inspection I realized, the error was for every time I used a lambda expression (via Retrolambda).
Manually uploading the app.apk
and testing.apk
to AWS Device Farm works fine.
The build fails for all lambda expressions, one of which I am pasting below:
Failed converting ECJ parse tree to Lombok for file /home/vedant/android/src/unacademy/app/src/main/java/com/unacademy/app/production/UploadHelper.java
java.lang.UnsupportedOperationException: Unknown ASTNode child: LambdaExpression
at lombok.ast.ecj.EcjTreeVisitor.visitOther(EcjTreeVisitor.java:368)
at lombok.ast.ecj.EcjTreeVisitor.visitEcjNode(EcjTreeVisitor.java:364)
at lombok.ast.ecj.EcjTreeConverter.visit(EcjTreeConverter.java:295)
at lombok.ast.ecj.EcjTreeConverter.toTree(EcjTreeConverter.java:236)
at lombok.ast.ecj.EcjTreeConverter.fillList(EcjTreeConverter.java:282)
at lombok.ast.ecj.EcjTreeConverter.fillList(EcjTreeConverter.java:252)
at lombok.ast.ecj.EcjTreeConverter.access$100(EcjTreeConverter.java:141)
at lombok.ast.ecj.EcjTreeConverter$2.visitMessageSend(EcjTreeConverter.java:1042)
at lombok.ast.ecj.EcjTreeVisitor.visitEcjNode(EcjTreeVisitor.java:156)
at lombok.ast.ecj.EcjTreeConverter.visit(EcjTreeConverter.java:295)
at lombok.ast.ecj.EcjTreeConverter.toTree(EcjTreeConverter.java:236)
at lombok.ast.ecj.EcjTreeConverter.fillList(EcjTreeConverter.java:282)
at lombok.ast.ecj.EcjTreeConverter.fillList(EcjTreeConverter.java:252)
at lombok.ast.ecj.EcjTreeConverter.toBlock(EcjTreeConverter.java:397)
at lombok.ast.ecj.EcjTreeConverter.access$1500(EcjTreeConverter.java:141)
at lombok.ast.ecj.EcjTreeConverter$2.visitMethodDeclaration(EcjTreeConverter.java:1241)
at lombok.ast.ecj.EcjTreeVisitor.visitEcjNode(EcjTreeVisitor.java:152)
at lombok.ast.ecj.EcjTreeConverter.visit(EcjTreeConverter.java:295)
at lombok.ast.ecj.EcjTreeConverter.toTree(EcjTreeConverter.java:236)
at lombok.ast.ecj.EcjTreeConverter.fillList(EcjTreeConverter.java:282)
at lombok.ast.ecj.EcjTreeConverter.fillList(EcjTreeConverter.java:252)
at lombok.ast.ecj.EcjTreeConverter.access$100(EcjTreeConverter.java:141)
at lombok.ast.ecj.EcjTreeConverter$2.createNormalTypeBody(EcjTreeConverter.java:563)
at lombok.ast.ecj.EcjTreeConverter$2.visitTypeDeclaration(EcjTreeConverter.java:486)
at lombok.ast.ecj.EcjTreeVisitor.visitEcjNode(EcjTreeVisitor.java:48)
at lombok.ast.ecj.EcjTreeConverter.visit(EcjTreeConverter.java:295)
at lombok.ast.ecj.EcjTreeConverter.toTree(EcjTreeConverter.java:236)
at lombok.ast.ecj.EcjTreeConverter.fillList(EcjTreeConverter.java:282)
at lombok.ast.ecj.EcjTreeConverter.fillList(EcjTreeConverter.java:252)
at lombok.ast.ecj.EcjTreeConverter.access$100(EcjTreeConverter.java:141)
at lombok.ast.ecj.EcjTreeConverter$2.visitCompilationUnitDeclaration(EcjTreeConverter.java:441)
at lombok.ast.ecj.EcjTreeVisitor.visitEcjNode(EcjTreeVisitor.java:264)
at lombok.ast.ecj.EcjTreeConverter.visit(EcjTreeConverter.java:295)
at com.android.tools.lint.EcjParser.parseJava(EcjParser.java:496)
at com.android.tools.lint.client.api.JavaVisitor.visitFile(JavaVisitor.java:245)
at com.android.tools.lint.client.api.LintDriver.checkJava(LintDriver.java:1527)
at com.android.tools.lint.client.api.LintDriver.runFileDetectors(LintDriver.java:1061)
at com.android.tools.lint.client.api.LintDriver.checkProject(LintDriver.java:906)
at com.android.tools.lint.client.api.LintDriver.analyze(LintDriver.java:435)
at com.android.tools.lint.client.api.LintDriver.analyze(LintDriver.java:376)
at com.android.tools.lint.LintCliClient.run(LintCliClient.java:128)
at com.android.build.gradle.internal.LintGradleClient.run(LintGradleClient.java:116)
at com.android.build.gradle.internal.LintGradleClient$run.call(Unknown Source)
at com.android.build.gradle.tasks.Lint.runLint(Lint.groovy:196)
at com.android.build.gradle.tasks.Lint.this$6$runLint(Lint.groovy)
at com.android.build.gradle.tasks.Lint$this$6$runLint$4.callCurrent(Unknown Source)
at com.android.build.gradle.tasks.Lint.lintSingleVariant(Lint.groovy:171)
at com.android.build.gradle.tasks.Lint$lintSingleVariant$3.callCurrent(Unknown Source)
at com.android.build.gradle.tasks.Lint.lint(Lint.groovy:73)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:75)
at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.doExecute(AnnotationProcessingTaskFactory.java:226)
at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:219)
at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:208)
at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:589)
at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:572)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:80)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:61)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:46)
at org.gradle.api.internal.tasks.execution.PostExecutionAnalysisTaskExecuter.execute(PostExecutionAnalysisTaskExecuter.java:35)
at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:64)
at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:58)
at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:42)
at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:52)
at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:53)
at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)
at org.gradle.api.internal.AbstractTask.executeWithoutThrowingTaskFailure(AbstractTask.java:310)
at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.executeTask(AbstractTaskPlanExecutor.java:79)
at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.processTask(AbstractTaskPlanExecutor.java:63)
at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.run(AbstractTaskPlanExecutor.java:51)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor.process(DefaultTaskPlanExecutor.java:23)
at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter.execute(DefaultTaskGraphExecuter.java:88)
at org.gradle.execution.SelectedTaskExecutionAction.execute(SelectedTaskExecutionAction.java:37)
at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:62)
at org.gradle.execution.DefaultBuildExecuter.access$200(DefaultBuildExecuter.java:23)
at org.gradle.execution.DefaultBuildExecuter$2.proceed(DefaultBuildExecuter.java:68)
at org.gradle.execution.DryRunBuildExecutionAction.execute(DryRunBuildExecutionAction.java:32)
at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:62)
at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:55)
at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:149)
at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:106)
at org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLauncher.java:86)
at org.gradle.launcher.exec.InProcessBuildActionExecuter$DefaultBuildController.run(InProcessBuildActionExecuter.java:90)
at org.gradle.tooling.internal.provider.ExecuteBuildActionRunner.run(ExecuteBuildActionRunner.java:28)
at org.gradle.launcher.exec.ChainingBuildActionRunner.run(ChainingBuildActionRunner.java:35)
at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:41)
at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:28)
at org.gradle.launcher.exec.DaemonUsageSuggestingBuildActionExecuter.execute(DaemonUsageSuggestingBuildActionExecuter.java:50)
at org.gradle.launcher.exec.DaemonUsageSuggestingBuildActionExecuter.execute(DaemonUsageSuggestingBuildActionExecuter.java:27)
at org.gradle.launcher.cli.RunBuildAction.run(RunBuildAction.java:40)
at org.gradle.internal.Actions$RunnableActionAdapter.execute(Actions.java:169)
at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:237)
at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:210)
at org.gradle.launcher.cli.JavaRuntimeValidationAction.execute(JavaRuntimeValidationAction.java:35)
at org.gradle.launcher.cli.JavaRuntimeValidationAction.execute(JavaRuntimeValidationAction.java:24)
at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:206)
at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:169)
at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:33)
at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:22)
at org.gradle.launcher.Main.doAction(Main.java:33)
at org.gradle.launcher.bootstrap.EntryPoint.run(EntryPoint.java:45)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.gradle.launcher.bootstrap.ProcessBootstrap.runNoExit(ProcessBootstrap.java:54)
at org.gradle.launcher.bootstrap.ProcessBootstrap.run(ProcessBootstrap.java:35)
at org.gradle.launcher.GradleMain.main(GradleMain.java:23)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.gradle.wrapper.BootstrapMainStarter.start(BootstrapMainStarter.java:33)
at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:130)
at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:48)
Source: (StackOverflow)
I've set up a very simple project to test the integration of Robolectric + Data Binding + Retrolambda. When I run the test suit, I get the following message:
Error:(30, 30) Gradle: error: cannot access AndroidHttpClient
class file for android.net.http.AndroidHttpClient not found
This is pretty odd since I don't use AndroidHttpClient anywhere.
The error occurs here, on the "activity" line:
@Before
public void setup() {
activity = Robolectric.setupActivity(MainActivity.class); // Error on this line
textView = (TextView) shadowOf(activity).findViewById(R.id.textView);
button = (Button) activity.findViewById(R.id.button);
editText = (EditText) activity.findViewById(R.id.editText);
}
The program never uses AndroidHttpClient. In fact, this is the entire program:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
final ActivityMainBinding binding = DataBindingUtil.setContentView(this, R.layout.activity_main);
binding.setUser(new User());
binding.button.setOnClickListener((v) -> {
binding.textView.setText(String.format("Hello, %s!", binding.editText.getText()));
binding.editText.setText("");
});
}
Ideas as to what's wrong?
Source: (StackOverflow)
I'm trying to compile an Android project unsuccessfully. The error message is:
Execution failed for task ':mobile:_compileAppDebug'.
java.lang.NoSuchMethodError: com.google.auto.common.MoreTypes.asTypeElements(Ljavax/lang/model/util/Types;Ljava/lang/Iterable;)Lcom/google/common/collect/ImmutableSet;
Here are my module's gradle dependencies in which I specify a number of libraries including google Auto:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile project(':library')
compile 'com.google.dagger:dagger:2.0-SNAPSHOT'
provided 'com.google.auto.value:auto-value:1.0-rc1'
apt 'com.google.dagger:dagger-compiler:2.0-SNAPSHOT'
provided 'org.glassfish:javax.annotation:10.0-b28'
compile 'com.jakewharton:butterknife:6.1.0'
compile 'com.f2prateek.dart:dart:1.1.0'
}
When I looked at the dependencies I thought I just needed google auto value since that is where the missing method resides but adding the provided does not resolve the issue.
The project gradle file includes the retrolambda plugin
dependencies {
classpath 'me.tatarka:gradle-retrolambda:2.5.0'
classpath 'com.android.tools.build:gradle:1.0.1'
classpath 'com.jakewharton.sdkmanager:gradle-plugin:0.12.+'
classpath 'io.fabric.tools:gradle:1.+'
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.4'
}
Can anyone help me identify which dependencies cause the compile error? Interestingly enough, when I copy the gradle files into an empty project everything runs fine.
Source: (StackOverflow)
I'm using retrofit and I feel like rxjava (with retrolambda) would be a good fit for the following flow:
- get list of widgets (http)
for each widget
a) get a list of articles (http) for the given widget type
b) save all those to db
c) take the first (latest) article in list and update widget.articleName and widget.articleUrl with appropriate values from this article
- transform back to list and complete
However I'm unsure what to do after step 2a. Here's my code so far
apiService.getWidgets(token)
.flatMapIterable(widgets -> widgets)
.flatMap(widget -> apiService.getArticles(token, widget.type))
...
.toList()
.subscribe(
modifiedWidgets -> saveWidgets(modifiedWidgets),
throwable -> processWidgetError(throwable)
);
I've played around with some operators but when chaining, I always seem to narrow down
too far (e.g. get a handle on a single article) and then no longer have access to the
original widget to make modifications.
@GET("/widgets")
Observable<List<Widget>> getWidgets(@Header("Authorization") String token);
@GET("/articles")
Observable<List<Article>> getArticles(@Header("Authorization") String token, @Query("type") String type);
Source: (StackOverflow)
android build failing on jenkins while runs successfully locally , below is the build output :
:app:compileDebugJavaNote: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
advice defined in hugo.weaving.internal.Hugo has not been applied [Xlint:adviceDidNotMatch]
:app:compileRetrolambdaDebugobjc[91376]: Class JavaLaunchHelper is implemented in both /Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home/bin/java and /Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home/jre/lib/libinstrument.dylib. One of the two will be used. Which one is undefined.
FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:compileRetrolambdaDebug'.
> Process 'command '/Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home/bin/java'' finished with non-zero exit value 1
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
Source: (StackOverflow)
I read the instructions for using Java8 for android development from this answer and (orfjackal/retrolambda).
I wanted to know if it is a good practice to use this technique to implement Java 8. Does this affects the application performance?
It is mentioned in the blog-
retrolambda It does this by transforming your Java 8 compiled bytecode so that it can run on an older Java runtime.
Source: (StackOverflow)
I have my Android studio set with these:
classpath "me.tatarka:gradle-retrolambda:3.2.2"
classpath 'me.tatarka.retrolambda.projectlombok:lombok.ast:0.2.3.a2'
And I am trying to use lambdas to know what I can do or not.
When I did the following code:
alertDialogBuilder.setPositiveButton("Okay", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.cancel();
}
});
The IDE grayed out the new DialogInterface.OnClickListener()
telling me it could be replaced with a lambda. Nothing more or less. After looking into several examples. I tried things like:
alertDialogBuilder.setPositiveButton("Okay", (DialogInterface dialog) -> {
dialog.cancel();
});
Also these:
alertDialogBuilder.setNegativeButton((DialogInterface) d -> d.cancel());
Among the errors:
Error:(99, 64) error: incompatible types: DialogInterface is not a functional interface
multiple non-overriding abstract methods found in interface DialogInterface
How should I use lambda in this case?
Source: (StackOverflow)
I have a problem with this code:
view.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN) {
view.getViewTreeObserver().removeOnGlobalLayoutListener(this);
} else {
//noinspection deprecation
view.getViewTreeObserver().removeGlobalOnLayoutListener(this);
}
getDefaultIntent();
}
});
I want to convert this code to use a lambda expression like this:
view.getViewTreeObserver().addOnGlobalLayoutListener(()->{
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN) {
view.getViewTreeObserver().removeOnGlobalLayoutListener(this);
} else {
//noinspection deprecation
view.getViewTreeObserver().removeGlobalOnLayoutListener(this);
}
getDefaultIntent();
});
But it wont work because now this
doesn't refer to the inner class.
Source: (StackOverflow)
An Android project, It was good with the older version of Android Studio. But after I updated the IDE version, An exception will occured when I build the project whith gradle.
Here is the problem:
Error:Execution failed for task ':jellyrefresh:compileReleaseJava'.
When running gradle with java 5, 6 or 7, you must set the path to jdk8, either with property retrolambda.jdk or environment variable
JAVA8_HOME
The thing is, my environment is Windows XP(I don't want to update), So I cannot install Java 8, so no need to tell me to do that. But I still want to use the Android Studio's latest version.
So what's the most resonable solution to this exception?
Source: (StackOverflow)