react-native-background-geolocation icon indicating copy to clipboard operation
react-native-background-geolocation copied to clipboard

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

Open RORrvtech opened this issue 7 years ago • 9 comments

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

1. 2. 3. 4.

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.

RORrvtech avatar Dec 24 '18 06:12 RORrvtech

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.

ohjeyong avatar Dec 31 '18 03:12 ohjeyong

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

RORrvtech avatar Dec 31 '18 03:12 RORrvtech

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

ohjeyong avatar Dec 31 '18 09:12 ohjeyong

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

scurtoni avatar Jan 22 '19 13:01 scurtoni

@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.

ohjeyong avatar Jan 23 '19 03:01 ohjeyong

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.

projectpublius avatar Jan 25 '19 16:01 projectpublius

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 avatar Jan 25 '19 16:01 mauron85

Just merge @scurtoni 's PR https://github.com/mauron85/background-geolocation-android/pull/25.

mauron85 avatar Jan 31 '19 10:01 mauron85

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

mauron85 avatar Jan 31 '19 11:01 mauron85