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?
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
My Android Studio Project (migrated to AndroidX) (TheInstrumentals) automatically imports android.app.Fragment whenever I make a Fragment from Android Studio's Fragment Wizard. How can I make it auto-import androidx.fragment.app.Fragment?
I've tried making a new Blank Fragment from another project (ViewPagerTest) (also migrated to AndroidX) and it imports androidx.fragment.app.Fragment automatically instead of the deprecated android.app.Fragment.
My other project (Udacity Project) (not in AndroidX) automatically imports android.support.v4.app.Fragment when the same thing was done.
com.mydomain.theinstrumentals.BlankFragment.java:
package com.mydomain.theinstrumentals;
import ...
import android.app.Fragment; //imported automatically
import ...
public class BlankFragment extends Fragment /*Fragment was strikedthrough */ {...}
com.mydomain.viewpagertest.BlankFragment.java:
package com.mydomain.viewpagertest;
import androidx.fragment.app.Fragment; //imported automatically
import ...
public class BlankFragment extends Fragment {...}
com.example.android.miwok.NumbersFragment:
package com.example.android.miwok.NumbersFragment;
import ...
import android.support.v4.app.Fragment; //imported automatically
import ...
public class NumbersFragment extends Fragment {...}
My answer to the linked post isn't old - the imports are still alphabetical and the options to auto import are modifiable in the settings
Short answer - AndroidX is extra, and later on the classpath, not on the core API, therefore it's listed later in the import menu
Plus, the Fragment wizard uses internal template files for creating new classes for all components, and can't assume that you have AndroidX as part of your code. If it did, then it would have to insert those plugins into the Gradle build, for example
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.