This is my MainActivity.java:
package com.drodriguez.my_rents;
import android.os.Bundle;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import io.flutter.embedding.android.FlutterActivity;
import io.flutter.embedding.engine.FlutterEngine;
public class MainActivity extends FlutterActivity {
#Override
protected void onCreate(#Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
#Override
public void configureFlutterEngine(#NonNull FlutterEngine flutterEngine) {
super.configureFlutterEngine(flutterEngine);
// FlutterYodo1Mas.getInstance().build(flutterEngine, this);
}
}
With that line commented it compiles ok but otherwise I get this with no more information:
MainActivity.java:21: error: cannot find symbol
FlutterYodo1Mas.getInstance().build(flutterEngine, this);
^
symbol: variable FlutterYodo1Mas
location: class MainActivity
1 error
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:compileDebugJavaWithJavac'.
More info: paste.ofcode.org/3bYrZ9afhH7YZWBkGwcTJWk
I tried removing /android/.gradle folder.
FlutterYodo1Mas.java is placed next to the MainActivity. I use Flutter but I don't think it's related to this error since these 2 files are .java
[Updated]
You need to import the package of FlutterYodo1Mas class in MainActivity.java.
import com.example.FlutterYodo1Mas;
On the second file, FlutterYodo1Mas.java, the first line wasn't your project name so you had to specify package com.drodriguez.my_rents;
It is tough to understand your issue without the complete stacktrace/error logs. I would suggest the efficient and simplest way, you can try delete the android folder, and run flutter create -a java . inside your app folder, to regenerate android folder, then merge your codes & configurations. There's no harm of trying, make sure you backup your existing code :)
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 am trying to use stripe_payment on my Flutter apps. It works fine on IOS simulators, but the app crashed instantly on Android.
I tried to put the stripe_payment package to a new project, and the app crashed on start as well.
The package version I'm using is: stripe_payment: ^0.0.9
Does anyone know how to use the package properly? Thanks a lot !
In your \android\app\src\main\java\com\example\yourProjectName\MainActivity.java
file you should have code similar to the code below:
package com.example.yourProjectName;
import android.os.Bundle;
//import io.flutter.app.FlutterActivity;
import io.flutter.app.FlutterFragmentActivity;
import io.flutter.plugins.GeneratedPluginRegistrant;
//public class MainActivity extends FlutterActivity {
public class MainActivity extends FlutterFragmentActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
GeneratedPluginRegistrant.registerWith(this);
}
}
In order it works for version ^0.1.0,
include this into your project's android/gradle.properties file
android.useAndroidX=true
android.enableJetifier=true
Use latest dependency
dependencies:
stripe_payment: ^0.1.0
use indentation properly.
then use below to get the dependency inside your project
flutter packages get
and import the dependency inside your page where you are using stripe_payment
import 'package:stripe_payment/stripe_payment.dart';
if imported dependency won't give you any error then you can use stripe_payment without any error
Extend your MainActivity with FlutterFragmentActivity.
Problem Solved..
If you use Flutter with Kotlin, then change the MainActivity.kt file's code to this.
android/app/src/main/kotlin/co/popcrn/app/MainActivity.kt
package YOUR_PACKAGE_NAME
import androidx.annotation.NonNull;
import io.flutter.embedding.android.FlutterFragmentActivity
import io.flutter.embedding.android.FlutterActivity
import io.flutter.embedding.engine.FlutterEngine
import io.flutter.plugins.GeneratedPluginRegistrant
class MainActivity: FlutterFragmentActivity() {
override fun configureFlutterEngine(#NonNull flutterEngine: FlutterEngine) {
GeneratedPluginRegistrant.registerWith(flutterEngine);
}
}
Getting cannot resolve symbol nullable error for my program.
#androidx.annotations.Nullable - nullable has redline under it.
package com.singularity.birdjumper;
import android.app.Activity;
import android.os.Bundle;
public class GameActivity extends Activity
{
#Override
protected void onCreate(#androidx.annotation.Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
}
just add this import statement
import android.support.annotation.Nullable;
For androidx, the import statement should be:
import androidx.annotation.Nullable;
Are you using the AndroidX library?
It would be worth adding them into the app gradle file,
//set the version to latest version
implementation 'androidx.appcompat:appcompat:1.1.0-rc01'
There is also a great answer over here for more information on AndroidX and migrating your projects over to it.
Android Studio adds both #androidx.annotation and #android.support.annotation problem
i hava the same problem,
sync project with gradle files or update gradle plug
I get the following error log when I run my Android app: http://pastebin.com/1jHEfdQ3 The app sometimes crashes in the simulator but most of the time it just displays a white screen. I can console.log one or two things until the app won't respond. R-R to refresh doesn't work. None of the dev tools work. I'm stumped with what to do at this point.
I'm running react native 0.38.0
EDIT:
I've tried cleaning my gradle and deleting and reinstalling my node modules.
One thing to note is that I am using React Native Navigation which means I had to modify MainApplication and MainActivity to the following:
MainActivity:
package com.prayerrequest;
import com.facebook.react.ReactActivity;
import com.reactnativenavigation.NavigationApplication;
import com.airbnb.android.react.maps.MapsPackage;
import com.cmcewen.blurview.BlurViewPackage;
import io.realm.react.RealmReactPackage;
import com.reactnativenavigation.controllers.SplashActivity;
public class MainActivity extends SplashActivity {
}
MainApplication:
package com.prayerrequest;
import com.facebook.react.ReactPackage;
import com.cmcewen.blurview.BlurViewPackage;
import io.realm.react.RealmReactPackage;
import com.airbnb.android.react.maps.MapsPackage;
import com.reactnativenavigation.NavigationApplication;
import java.util.Arrays;
import java.util.List;
public class MainApplication extends NavigationApplication {
#Override
public boolean isDebug() {
// Make sure you are using BuildConfig from your own application
return BuildConfig.DEBUG;
}
#Override
public List<ReactPackage> createAdditionalReactPackages() {
return Arrays.<ReactPackage>asList(
new RealmReactPackage(),
new BlurViewPackage(),
new MapsPackage()
);
}
}
I've crossposted on React Native's issues page here
The issue seems to be 'Couldn't load memtrack module (No such file or directory)'
It looks like there's an issue with the simulator.
This is a config of my fully functional simulator:
Lots of other suggestions can be found here:
Couldn't load memtrack module Logcat Error
I had a similar problem. I would get this white screen when trying to get it to run on device.
The problem was when I would do adb devices or react-native run-android I would get "ADB is Not Recognized as an internal or external command".
So my fix was to add the path to adb.exe's parent directory to my Environment Variables and then restart my command prompts.I then ran react-native run-android and on startup no more red screen showing the completely useless error message Error calling AppRegistry.runApplication! :)
So I found ADB was located in my folder:
C:\Users\dell\AppData\Local\Android\sdk\platform-tools\adb.exe
I am on a Windows 10 system. dell is my user name of the computer.
So I went to System Environment Variables then found "Path" then clicked "Edit", then clicked "New" and added in "C:\Users\dell\AppData\Local\Android\sdk\platform-tools".
So when i create a new android application project with ANDROID 6.0 library i instantly get the a lot of errors in the MainActivity code.
Starting with The import android.support.v7.app cannot be resolved
To The method onCreate(Bundle) of type MainActivity must override or implement a supertype method
When i add the appcompat.v7 library obviously Some of the errors related are gone but other are coming instead. Like:
The type android.support.v4.widget.DrawerLayout$DrawerListener cannot be resolved. It is indirectly referenced from required .class files on the package line.
And still The method onCreateOptionsMenu(Menu) of type MainActivity must override or implement a supertype method.
Ok. So add the v4 jar too. Ok. I added it too to the project properties and no errors!
Wait,but when i run the app now I get a ClassNotFoundException.
So what the hell android 6.0???
Thanks for the help.
EDIT
MainActivity.java:
package com.minyan.get.dl;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
public class MainActivity extends AppCompatActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
}
The main reason is that Android Studio is the main IDE now.
Eclipse is no longer supported.
I suggest switching to Android Studio.