0

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

Dani
  • 3,128
  • 2
  • 43
  • 91

2 Answers2

0

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 :)

Wesley
  • 186
  • 6
  • if I do that I create an android folder without Kotlin support and that's a problem for some packages. I opened this a few days ago: https://github.com/ja2375/add_2_calendar/issues/80#event-5241646099 – Dani Sep 03 '21 at 20:42
  • https://stackoverflow.com/questions/60186072/how-to-run-with-stacktrace-option-to-get-the-stack-trace You can try running the compileDebugJavaWithJavac Gradle task manually. cd android ./gradlew compileDebugJavaWithJavac --stacktrace – Wesley Sep 04 '21 at 08:44
  • basically the error is the same, but not sure if this extra info helps: paste.ofcode.org/3bYrZ9afhH7YZWBkGwcTJWk – Dani Sep 04 '21 at 09:48
  • You need to import your class in your MainActivity.java. import com.xxx.FlutterYodo1Mas; – Wesley Sep 04 '21 at 15:05
  • what stands xxx for? Sorry for the silly question but I tried different combinations – Dani Sep 04 '21 at 15:41
  • xxx is the package of FlutterYodo1Mas class. Example: com.example.FlutterYodo1Mas – Wesley Sep 04 '21 at 15:54
  • aaaah that was the issue. On the second file, FlutterYodo1Mas.java, the first line wasn't my project name so I had to specify package com.drodriguez.my_rents;. – Dani Sep 04 '21 at 16:49
  • Create another answer with above info and I'll accept it ;) – Dani Sep 04 '21 at 16:49
0

[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;

Wesley
  • 186
  • 6