I recently transferred my Flutter project from one Firebase project registration to a different one. I changed the package name everywhere in my Flutter project and replaced the google-services.json file.
My issue is that whenever I Build by APK, it crashes because there are errors in the android/GeneratedPluginRegistrant.java file. My code for the file is as follows; I have pointed out the errors in the code:
package io.flutter.plugins;
import androidx.annotation.Keep;
import androidx.annotation.NonNull;
import io.flutter.embedding.engine.FlutterEngine;
import io.flutter.embedding.engine.plugins.shim.ShimPluginRegistry;
/**
* Generated file. Do not edit.
* This file is generated by the Flutter tool based on the
* plugins that support the Android platform.
*/
#Keep
public final class GeneratedPluginRegistrant {
public static void registerWith(#NonNull FlutterEngine flutterEngine) {
ShimPluginRegistry shimPluginRegistry = new ShimPluginRegistry(flutterEngine);
//THE FOLLOWING FOUR LINES ALL HAVE ERRORS:
io.flutter.plugins.firebase.cloudfirestore.CloudFirestorePlugin.registerWith(shimPluginRegistry.registrarFor("io.flutter.plugins.firebase.cloudfirestore.CloudFirestorePlugin"));
io.flutter.plugins.firebaseauth.FirebaseAuthPlugin.registerWith(shimPluginRegistry.registrarFor("io.flutter.plugins.firebaseauth.FirebaseAuthPlugin"));
flutterEngine.getPlugins().add(new io.flutter.plugins.firebase.core.FirebaseCorePlugin());
flutterEngine.getPlugins().add(new io.flutter.plugins.googlesignin.GoogleSignInPlugin());
}
}
The errors are basically saying that they can't resolve the "firebase", "firebaseauth", and "googlesignin" packages.
My APK was building just fine before I transferred my project to a different Firebase account. How do I fix these errors? Has anyone else seen errors like this in their GeneratedPluginRegistrant.java file?
Related
When I build my Flutter app, this error shows:
error: incompatible types: MainActivity cannot be converted to FlutterEngine GeneratedPluginRegistrant.registerWith(this);
I went to the github of class and saw the difference: https://github.com/theyakka/fluro/blob/master/example/android/app/src/main/java/io/flutter/plugins/GeneratedPluginRegistrant.java
If I put this in my project, when I build application, my class change automatically for this:
package io.flutter.plugins;
import androidx.annotation.Keep;
import androidx.annotation.NonNull;
import io.flutter.embedding.engine.FlutterEngine;
/**
* Generated file. Do not edit.
* This file is generated by the Flutter tool based on the
* plugins that support the Android platform.
*/
#Keep
public final class GeneratedPluginRegistrant {
public static void registerWith(#NonNull FlutterEngine flutterEngine) {
}
}
I follow this tutorial:https://www.youtube.com/watch?v=NXuAzXY_KOo
I need to run my app in background to get the current location, but don't works.
You need import the plugin,
import io.flutter.plugin.common.PluginRegistry;
and extend your class with FlutterActivity.
I'm doing a face recognition android application with opencv. When i try to run the project i get "Error:(3, 18) error: cannot find symbol class R" error. How can i solve this?
I'm trying to do a face recognition application and for that i'm using opencv. I wanted to try out a sample first so i followed few of the samples that were available.
I downloaded opencv4.0.1 and imported to my app in android studio -> Next changed the opencv gradle according to my gradle settings -> gradle files were synced succeessfully without errors -> Next as the tutorial stated i added the module dependency to my application where i selected the opencv module as the dependency.
Synced my gradle files. All was synced successfully.
I tried to run the application but the comes the error " Error:(3, 18) error: cannot find symbol class R" following "Error:(48, 78) error: package R does not exist".
This is one of the tutorials i followed as i'm completely new to opencv : https://www.learn2crack.com/2016/03/setup-opencv-sdk-android-studio.html
I already tried, cleaning & building the project again, invalidating and restarting the project, checking xml errors & etc. But none worked.
And this error is coming in some opencv files which i have mentioned below.
package org.opencv.android;
import org.opencv.R;
import android.content.Context;
import android.content.res.TypedArray;
import android.opengl.GLSurfaceView;
import android.util.AttributeSet;
import android.util.Log;
import android.view.SurfaceHolder;
public class CameraGLSurfaceView extends GLSurfaceView {
private static final String LOGTAG = "CameraGLSurfaceView";
public interface CameraTextureListener {
/**
* This method is invoked when camera preview has started. After this method is invoked
* the frames will start to be delivered to client via the onCameraFrame() callback.
* #param width - the width of the frames that will be delivered
* #param height - the height of the frames that will be delivered
*/
public void onCameraViewStarted(int width, int height);
/**
* This method is invoked when camera preview has been stopped for some reason.
* No frames will be delivered via onCameraFrame() callback after this method is called.
*/
public void onCameraViewStopped();
just replace :
res.srcDirs = ['/build/master_pack-android/opencv/modules/java/android_sdk/android_gradle_lib/res']
with :
res.srcDirs = ['res']
you can use Ctrl+Shift+F to find this line of code in the android studio OR navigate to gradle file of the OpenCV library
I am playing with react native for android and i have special interest with sqlite.
I try to use the sqlite lib here react-native-sqlite-storage buy i always have BUILD FAILED when "run-android". I'm a little lost at step 4 (How to use Android)
configuring the MainActivity
The error:
E:\Documents\Visual Studio CODE\MyApp\android\app\src\main\java\com\myapp\MainActivity.java:22: error: cannot find symbol
protected List getPackages() {
^
symbol: class List
location: class MainActivity
...
Have somebody a very simple sample project for android to see the correct conf?
thanks in advance.
You are missing import statement for the List.
import java.util.List;
#Override
protected List getPackages() {
//noinspection RedundantArrayCreation
return Arrays.asList(new ReactPackage[]{
new MainReactPackage(),
});
}
Any java IDE has some kind of fix import function so it would automatically propose you correct solution.
Try android studio it's free and react-native automatically generate gradle configuration. All you need to do is to import your project folder with gradle files (android by default) into IDE and press ctrl+space to turn IntelliSense on.
You should change MainAplication.java and not MainActivity.java
We are trying to use the Robolectric testing framework in Android Studio in order to test the Facebook API. The Facebook Login button works so the Facebook API is working. However, the following test fails:
package com.airportapp.test.Models;
import android.app.Activity;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.annotation.Config;
import org.robolectric.Robolectric;
import com.airportapp.test.MyRobolectricTestRunner;
import com.airportapp.LoginActivity;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
#RunWith(MyRobolectricTestRunner.class)
public class LoginActivityTest {
#Before
public void setup() {
//do whatever is necessary before every test
}
#Test
public void testActivityFound() {
Activity activity = Robolectric.buildActivity(LoginActivity.class).create().get();
Assert.assertNotNull(activity);
}
}
And the error is that Android Studio could not find the android.support file when we run the tests. You can see the error here:
The other error that shows up is:
android.view.InflateException: XML file app/src/main/res/layout/activity_login.xml line #-1 (sorry, not yet implemented): Error inflating class com.facebook.widget.LoginButton
So Android Studio is not happy with the facebook login button as well :( But it works... We think that we need to import something, but we don't know where to put it.
The InflateException is because Robolectric cannot find the resources from the Facebook SDK. To solve this, the project.properties file has to be updated to point to the Facebook SDK project. Do this by adding the following line to it:
android.library.reference.1={Path}
{Path} should be a relative path, from the project.properties file to the folder containing the AndroidManifest.xml of the Facebook SDK project. In my case that is ../../build/intermediates/exploded-aar/com.facebook.android/facebook/3.21.0.
Note that this works for all Android Library Projects which contain resources that aren't found by Robolectric. Further reading: here and here. Also, more documentation about project.properties can be found here. Note that in my project the Robolectric tests are located in the Android app project itself. So you could also try placing the project.properties file in the same directory as the AndroidManifest.xml used for testing.
As for your first problem; I have no personal experience with it. But it appears to be because Gradle cannot find the support libraries when compiling the unit tests. The answer from this question should fix it.
I am trying use the GPE code for App-Android Android-App communication. Both the two new created folders (Android, AppEngine) have errors. I think the problem is that there are
errors with the packages:
import com.google.web.bindery.requestfactory.shared.InstanceRequest;
import com.google.web.bindery.requestfactory.shared.Request;
import com.google.web.bindery.requestfactory.shared.RequestContext;
import com.google.web.bindery.requestfactory.shared.RequestFactory;
import com.google.web.bindery.requestfactory.shared.ServiceName;
It says "The import com.google.web cannot be resolved." I tried adding everything able to be checked checked in the build path. I also know I installed the Web Toolkit and everything. What is wrong?
Statements like the following also have error markings:
#ProxyForName(value = "com.glm.server.Message",
locator = "com.glm.server.MessageLocator") and actually there are so many errors it must be the imports.