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
Related
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);
}
}
I want to use LibVLC in my Android application.
I added below line to gradle dependencies to use precompiled LibVLC library.
compile 'de.mrmaffen:vlc-android-sdk:3.0.0'
When I use below code i get this error.
Cannot resolve method 'getInstance()'
My initialization code is
mLibVLC = LibVLC.getInstance();
My imports are
import org.videolan.libvlc.EventHandler;
import org.videolan.libvlc.IVideoPlayer;
import org.videolan.libvlc.LibVLC;
import org.videolan.libvlc.Media;
import org.videolan.libvlc.MediaList;
and my class definition is
public class VideoActivity extends Activity implements IVideoPlayer
Should i add another definitions to my project to solve this problem?
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.
In thefollowing Code, I get a problem when following the Android beginners tutorial at http://developer.android.com/training/basics/firstapp/starting-activity.html#StartActivity
Eclipse is saying: supressLint cannot be resolved to a type error with a small x next to that line #SuppressLint("NewApi").
I cannot save and run the application.
package com.example.myfirstapp;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.view.MenuItem;
import android.support.v4.app.NavUtils;
import android.annotation.TargetApi;
import android.os.Build;
public class DisplayMessageActivity extends Activity {
#SuppressLint("NewApi")
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_display_message);
// Make sure we're running on Honeycomb or higher to use ActionBar APIs
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
// Show the Up button in the action bar.
getActionBar().setDisplayHomeAsUpEnabled(true);
}
}
#Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
NavUtils.navigateUpFromSameTask(this);
return true;
}
return super.onOptionsItemSelected(item);
}
}
Try this:
import android.annotation.SuppressLint;
The issue is that you need to organize your imports. This is frequently a cause for the "cannot resolve to a type" error. You haven't imported the code package which contains the definition of SuppressLint, so the compiler doesn't know what it means yet.
In Eclipse, a quick way to organize imports is Ctrl+Shift+O on Windows or Cmd+Shift+O on Mac. This automatically checks for packages you need and adds them to your import statements.
To use #SuppressLint you will want to make sure that you have the android.annotation.SuppressLint package.
While the OP's question is for Eclipse, I faced similar issue on Android Studio and the issue was because of the "CSV plugin"
Uninstalling this plugin, resolved the issue for me.
(Might be useful for those who're having similar scenario and are landing on this question because of this plugin issue)
I think this helps you because supresslint annotation was added in API level 16
set your build SDK to 16 or higher
Copy tools/support/annotations.jar from your Android SDK to the project
Try this.
I have a class set up as an EViewGroup. In it, I'm trying to reference another Activity set up as an EActivity. For some reason, the import isn't resolving, but it resolves fine if I reference the Activity in question from another EActivity.
The code compiles fine using ant on our Jenkins server, but doesn't compile within Ecipse.
Any ideas?
Here's some code for ViewGroup:
import android.app.Activity;
import android.content.Intent;
import com.googlecode.androidannotations.annotations.Click;
import com.googlecode.androidannotations.annotations.EViewGroup;
#EViewGroup
public class MainMenu extends SlidingMenu
{
public void navigate(Class<? extends Activity> klass)
{
getContext().startActivity(new Intent(getContext(), klass));
toggle();
}
#Click(R.id.textView_bring_it)
public void bringItClick()
{
navigate(ActivityBringIt_.class);
}
}
The compile errors I'm seeing:
The import com.beachbody.p90x.bringit.ActivityBringIt_ cannot be
resolved
The method navigate(Class) in the type MainMenu
is not applicable for the arguments (Class)
ActivityBringIt_ cannot be resolved to a type
Here is my .factorypath file:
<factorypath>
<factorypathentry kind="WKSPJAR" id="/common/compile-libs/androidannotations-2.7.1.jar" enabled="true" runInBatchMode="false"/>
</factorypath>
It seems that ActivityBringIt_ isn't generated. Your compiling errors are just noises because of that.
Mostly AA can't generate subclasses if you have errors in you Android's xml files.
You should take a look on this.
Also, could you copy/paste your .factory file ?
Thanks DayS for pointing me in the right direction. There is a bug in Eclipse causing this issue. The workaround is to import the entire package in question. In my case it is:
import com.beachbody.p90x.bringit.*;
Here is the bug report w/ Eclipse:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=387956