Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error: cannot find symbol Assert.assertNotNull("Context can not be null!", mContext #340

Closed
RORrvtech opened this issue Dec 24, 2018 · 9 comments
Labels
bug good first issue resolved Indicating the issue has been successfully resolved.

Comments

@RORrvtech
Copy link

RORrvtech commented Dec 24, 2018

Your Environment

  • Plugin version: 0.5 Alpha latest
  • Platform: Android
  • OS version: Mac high sierra
  • Device manufacturer and model:
  • Running in Simulator: No
  • React Native version: 0.57.7
  • Plugin configuration options:
  • Link to your project:

Context

Expected Behavior

App should build succesfullt

Actual Behavior

Not building

Possible Fix

Should use new Convention

Steps to Reproduce

Context

App not builds successfully

Debug logs

Task :react-native-mauron85-background-geolocation-common:compileDebugJavaWithJavac FAILED
/Users/user/Documents/apps/xxx/node_modules/react-native-mauron85-background-geolocation/android/common/src/main/java/com/marianhello/bgloc/service/LocationServiceIntentBuilder.java:26: error: package junit.framework does not exist
import junit.framework.Assert;
^
/Users/user/Documents/apps/xxxx/node_modules/react-native-mauron85-background-geolocation/android/common/src/main/java/com/marianhello/bgloc/service/LocationServiceIntentBuilder.java:162: error: cannot find symbol
Assert.assertNotNull("Context can not be null!", mContext);
^
symbol: variable Assert
location: class LocationServiceIntentBuilder
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.

@ohjeyong
Copy link

I have a same issue. I found out that if there's test code located in src, it caused this kind of build failure.
This problem appears at 0.5.0-alpha.49, 0.5.0-alpha.50 version. If you downgrade to 0.5.0-alpha.48, it will be solved.

@RORrvtech
Copy link
Author

RORrvtech commented Dec 31, 2018

its not true, if you use example above which used 0.5.0-alpha.50 successfully compiled. its more like a gradle setting which is not mentioned in Readme.md

Example[] https://github.com/mauron85/react-native-background-geolocation-example/blob/master/package.json

@ohjeyong
Copy link

Oh, I use gradle version 3.2.1 and many other native libraries, so one of them could be a problem.

@scurtoni
Copy link

I have the same issue too for the same version of the library.
By inspecting a little bit the code what it seem to me is that junit dependency is declared for test and used instead in main. Moreover I don't understand why is necessary an Assert inside the LocationServiceIntentBuilder class but maybe is something I miss.
I hope this help.
Meanwhile I will inspect a bit more and hopefully I will provide a possible solution

@ohjeyong
Copy link

@scurtoni
I agree. The test code in LocationServiceIntentBuilder.java cause the problem and LocationServiceIntentBuilder.java was added from 0.5.0-alpha.49. So, downgrading to 0.5.0-alpha.48 will solve the problem, but it will be great if test code in LocationServiceIntentBuilder.java file will be removed.

@projectpublius
Copy link

projectpublius commented Jan 25, 2019

I also experienced this compilation error after updating the following settings in my project build.gradle:

  buildToolsVersion = "27.0.3" -> "28.0.2"
  compileSdkVersion = 27 -> 28
  supportLibVersion = "27.1.1" -> "28.0.0"

As mentioned above, reverting to 0.5.0-alpha.48 fixes the issue.

@mauron85
Copy link
Owner

mauron85 commented Jan 25, 2019

By inspecting a little bit the code what it seem to me is that junit dependency is declared for test and used instead in main. Moreover I don't understand why is necessary an Assert inside the LocationServiceIntentBuilder class but maybe is something I miss.

Apparently I made mistake using Assert from junit testing framework. Consider this as a bug. Need to be fixed. But on the other side, using Assert is perfectly fine here. You really don't want to continue when there is missing (null) Context. But it should be assert from standard library, not from junit.

@mauron85 mauron85 added bug help wanted good first issue resolved Indicating the issue has been successfully resolved. and removed help wanted labels Jan 25, 2019
@mauron85
Copy link
Owner

Just merge @scurtoni 's PR mauron85/background-geolocation-android#25.

@mauron85
Copy link
Owner

FYI: New version 0.5.0 with fix has been published to npm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug good first issue resolved Indicating the issue has been successfully resolved.
Projects
None yet
Development

No branches or pull requests

5 participants