Issue with RNGestureHandlerEnabledRootView not being supported : java.lang.UnsupportedOperationException - java

I am getting an issue with react-native-gesture-handler library. I have upgraded to the latest version "^2.9.0". I am not able to run my build as it crashes on opening the app giving me a summary:- java.lang.UnsupportedOperationException: Your application is configured to use RNGestureHandlerEnabledRootView which is no longer supported.
I have read the documentation for migrating off RNGHEnabledRootView but that too doesn't solve the problem. I have changed MainActivity.java file by editing :
import com.swmansion.gesturehandler.RNGestureHandlerPackage;
But getting issue with :
#Override
protected ReactActivityDelegate createReactActivityDelegate() {
return new ReactActivityDelegateWrapper(this, new ReactActivityDelegate(this, getMainComponentName()) {
#Override
protected ReactRootView createRootView() {
return new RNGestureHandlerEnabledRootView(MainActivity.this);
}
});
}
error: cannot find symbol
return new RNGestureHandlerEnabledRootView(MainActivity.this);
^
symbol: class RNGestureHandlerEnabledRootView
Execution failed for task ':app:compileDebugJavaWithJavac'.

Related

Cannot resolve symbol 'BillingResponse'

I have implemented Billing Library from the following url
https://developer.android.com/google/play/billing/billing_library_overview#java
I am getting error on this line
if (billingResult.getResponseCode() == BillingResponse.OK) {
it says Cannot resolve symbol 'BillingResponse'
here is the complete code from above link
billingClient.startConnection(new BillingClientStateListener() {
#Override
public void onBillingSetupFinished(BillingResult billingResult) {
if (billingResult.getResponseCode() == BillingResponse.OK) {
// The BillingClient is ready. You can query purchases here.
}
}
#Override
public void onBillingServiceDisconnected() {
// Try to restart the connection on the next request to
// Google Play by calling the startConnection() method.
}
});
I have added following dependency in my apps build.gradle file
dependencies {
...
implementation 'com.android.billingclient:billing:2.1.0'
}
but I am getting error
I cannot even import it manually
import com.android.billingclient.api.BillingClient.BillingResponse;
I know its simple solution is to just replace
BillingResponse.OK
with
BillingClient.BillingResponseCode.OK
but my question is why its not given in documentation then?
I checked the source codes and figured out the correct code.
Though the code on google documentation says billingResult.getResponseCode() == BillingResponse.OK it should be billingResult.getResponseCode() == BillingClient.BillingResponseCode.OK
So all you need to do is replace BillingResponse.OK with BillingClient.BillingResponseCode.OK

AIDE error: Method onRewardedVideoCompleted does not override method from superclass

I am getting this AIDE (Android IDE) error: "Method onRewardedVideoCompleted does not override method from superclass". The weird part is there is no errors in Android Studio. I followed this guide: https://developers.google.com/admob/android/rewarded-video
I am getting this error in AIDE:
Here is the full code: https://pastebin.com/TJCPw5BH
#Override
public void onRewardedVideoCompleted() {
Toast.makeText(this, "onRewardedVideoCompleted", Toast.LENGTH_SHORT).show();
}
All help appreciated!
I also had this issue.
This is what I did to resolve it:
In RNFirebaseAdMobRewardedVideo.java:
#Override
public void onRewardedVideoCompleted() {
// Toast.makeText(this, "onRewardedVideoCompleted",
// Toast.LENGTH_SHORT).show();
sendEvent("onRewardedVideoCompleted", null);
}
And if you receive this error after adding that code: Error:Execution failed for task ':app:transformClassesWithDexForRelease', add this to your app build.gradle:
defaultConfig {
multiDexEnabled true
}
Please let me know if this works!

NoClassDefFoundError while running Roboelectric Unit Test

I am trying to run a Roboelectric Unit test to test if the intended activity is getting started or not, but as I'm getting the following error :
java.lang.NoClassDefFoundError: Could not initialize class
android.os.AsyncTask
I am looking for the solution but no luck so far, Has anyone faced this issue before.
Find below my Test class
#RunWith(RobolectricTestRunner.class)
#Config(constants = BuildConfig.class, manifest = "AndroidManifest.xml", minSdk = 21, maxSdk = 21, application = MyApplication.class)
#PowerMockIgnore({"org.mockito.*", "org.robolectric.*", "android.*"})
public class PushManagerTest {
#Test
public void shouldLaunchNewActivity() throws Exception {
Activity testActivity = Robolectric.setupActivity(TestActivity.class);
Intent expectedIntent = new Intent(testActivity, NewActivity.class);
Intent actualIntent = ShadowApplication.getInstance().getNextStartedActivity();
assertEquals(expectedIntent.getComponent(), actualIntent.getComponent());
}
}
I finally fixed it, dont know if it is the correct way or nor but the tests are working as expected
I had to add the following lines in the onCreate of my Application class
try{
Class.forName("android.os.AsyncTask");
}catch(Throwable ignore) {
// ignored
}
Hope it helps someone

RoboSpice throwing okhttp exceptions

I use RoboSpice-Retrofit for calling my server REST api which has been working without problems until a few days ago when every single call now throws an exception, Example:
D/Retrofit: java.lang.NoSuchMethodError: No direct method <init>(Lcom/squareup/okhttp/OkHttpClient;Lcom/squareup/okhttp/Request;ZZZLcom/squareup/okhttp/Connection;Lcom/squareup/okhttp/internal/http/RouteSelector;Lcom/squareup/okhttp/internal/http/RetryableSink;Lcom/squareup/okhttp/Response;)V in class Lcom/squareup/okhttp/internal/http/HttpEngine; or its super classes (declaration of 'com.squareup.okhttp.internal.http.HttpEngine' appears in /data/app/com.company.app.customerapp-1/base.apk)
at com.squareup.okhttp.internal.huc.HttpURLConnectionImpl.newHttpEngine(HttpURLConnectionImpl.java:362)
at com.squareup.okhttp.internal.huc.HttpURLConnectionImpl.initHttpEngine(HttpURLConnectionImpl.java:312)
at com.squareup.okhttp.internal.huc.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:377)
at com.squareup.okhttp.internal.huc.HttpURLConnectionImpl.getResponseCode(HttpURLConnectionImpl.java:497)
at retrofit.client.UrlConnectionClient.readResponse(UrlConnectionClient.java:73)
at retrofit.client.UrlConnectionClient.execute(UrlConnectionClient.java:38)
at retrofit.RestAdapter$RestHandler.invokeRequest(RestAdapter.java:321)
at retrofit.RestAdapter$RestHandler.invoke(RestAdapter.java:240)
at java.lang.reflect.Proxy.invoke(Proxy.java:393)
at $Proxy0.getTest(Unknown Source)
at com.adoperator.tidyapp.TestActivity$TestRequest.loadDataFromNetwork(TestActivity.java:67)
at com.adoperator.tidyapp.TestActivity$TestRequest.loadDataFromNetwork(TestActivity.java:54)
at com.octo.android.robospice.request.CachedSpiceRequest.loadDataFromNetwork(CachedSpiceRequest.java:48)
at com.octo.android.robospice.request.DefaultRequestRunner.processRequest(DefaultRequestRunner.java:150)
at com.octo.android.robospice.request.DefaultRequestRunner$1.run(DefaultRequestRunner.java:217)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:423)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
at java.lang.Thread.run(Thread.java:818)
D/Retrofit: ---- END ERROR
dependencies:
compile 'com.octo.android.robospice:robospice:1.4.14'
compile 'com.octo.android.robospice:robospice-cache:1.4.14'
compile 'com.octo.android.robospice:robospice-retrofit:1.4.14'
I suspect based on the exception that there is something wrong with the compiler, but I just tested on another computer with a fresh install of Java and Android Studio on the same project but same problems still...
This error is driving me crazy...
Anyone knows anything that could be of help? Any help is highly appreciated.
EDIT
MainActivity.java:
SpiceManager spiceManager = new SpiceManager(TestAPIService.class);
protected void onStart() {
super.onStart();
spiceManager.start(this);
spiceManager.execute(new TestRequest(), new RequestListener<ResponseData>() {
...
});
}
TestAPIService.java:
public class TestAPIService extends RetrofitGsonSpiceService {
#Override
public void onCreate() {
super.onCreate();
addRetrofitInterface(TestAPI.class);
}
#Override
protected String getServerUrl() {
return "http://192.168.0.2";
}
}
TestAPI.java:
public interface TestAPI {
#GET("/test")
ResponseData getTest();
}
TestRequest.java:
public class TestRequest extends RetrofitSpiceRequest<ResponseData, TestAPI> {
public TestRequest() {
super(ResponseData.class, TestAPI.class);
}
#Override
public ResponseData loadDataFromNetwork() throws Exception {
ResponseData response;
try {
response = getService().getTest();
}
catch (Exception e) {
e.printStackTrace();
throw e;
}
return response;
}
}
The NoSuchMethodError is happening because HttpURLConnectionImpl is trying to invoke a constructor on HttpEngine that is not defined. Now your project depends on:
com.octo.android.robospice:robospice-retrofit:1.4.14
Which depends on:
com.squareup.retrofit:retrofit:1.6.1
Which depends on both:
com.squareup.okhttp:okhttp:2.0.0
and
com.squareup.okhttp:okhttp-urlconnection:2.0.0
As of version 2.0.0, HttpURLConnectionImpl is in the okhttp-urlconnection module and HttpEngine is in the okhttp module.
The retrofit.client.UrlConnectionClient portion of your stack trace correctly matches retrofit:1.6.1, but the com.squareup.okhttp.internal.huc.HttpURLConnectionImpl portion doesn't match okhttp-urlconnection:2.0.0; it matches okhttp-urlconnection:2.4.0. The constructor that the NoSuchMethodError is complaining about is indeed defined in okhttp:2.4.0, so that means there is a different HttpEngine on your classpath, most likely from a different version of okhttp that is getting pulled in by a transitive dependency. You should be able to fix the problem by specifying the following dependencies:
compile('com.squareup.okhttp:okhttp:2.0.0') {
force = true
}
compile('com.squareup.okhttp:okhttp-urlconnection:2.0.0') {
force = true
}
If that doesn't work for whatever reason, the solution to your problem will still be to get your versions of okhttp and okhttp-urlconnection synced up and at a version that is compatible with your version of retrofit. Declare dependencies similar to above, find the jars that contain HttpURLConnectionImpl and HttpEngine, figure out how they're getting pulled in to your build, and use exclusions to get rid of problematic transitive dependencies.

Android : Should I remove #Override from facebook.java?

I am trying to integrate facebook to my Android application. When i added internet permission in the project and have generated App_ID but when I put facebook files in to my project it gives these errors as shown in pic.
Now should I remove #Override or am I missing something.
If I put this code into my OnCreate method it also gives errors to remove #Override.
facebook.authorize(this, new DialogListener() {
#Override
public void onComplete(Bundle values) {}
#Override
public void onFacebookError(FacebookError error) {}
#Override
public void onError(DialogError e) {}
#Override
public void onCancel() {}
});
Should I include facebook.apk if yes then Where to add this? please help
I followed many tutorials but could not resolve these errors.
This is most likely because you are switching between Java 1.5 and Java 1.6. In 1.5 you couldn't mark interface implementations with #Override, but you can in 1.6.
#Override annotation error (android prefs)
Bug with Override annotations in Eclipse

Categories