While working with firebase UI I am getting Unable to find explicit activity class com.firebase.ui.auth.KickoffActivity
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
FirebaseApp.initializeApp(this);
setContentView(R.layout.activity_main);
FirebaseApp.initializeApp(this);
mAuth=FirebaseAuth.getInstance();
mAuthListner=new FirebaseAuth.AuthStateListener() {
#Override
public void onAuthStateChanged(#NonNull FirebaseAuth firebaseAuth) {
FirebaseUser user=firebaseAuth.getCurrentUser();
if(user!=null){
Toast.makeText(getApplicationContext(),"Sign in success",Toast.LENGTH_SHORT).show();
}
else {
startActivityForResult(AuthUI.getInstance()
.createSignInIntentBuilder()
.setIsSmartLockEnabled(false)
.setProviders(AuthUI.EMAIL_PROVIDER,AuthUI.GOOGLE_PROVIDER).build(),
RC_SIGN_IN);
}
}
};
}
Full error message
android.content.ActivityNotFoundException: Unable to find explicit activity class {com.example.flamanco.trackme/com.firebase.ui.auth.KickoffActivity}; have you declared this activity in your AndroidManifest.xml? at android.app.Instrumentation.checkStartActivityResult
Added dependencies on app/.gradle file
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:24.2.1'
compile 'com.google.firebase:firebase-core:10.0.1'
compile 'com.google.firebase:firebase-auth:10.0.1'
compile 'com.firebaseui:firebase-ui-auth:1.1.1'
}
apply plugin: 'com.google.gms.google-services'
also added plugin in build gradle
classpath 'com.google.gms:google-services:3.0.0'
Finally I did added SHA1 fingerprint in my firebase console project.
Do I need to add auth.kickOff activity in manifest file
android.content.ActivityNotFoundException: Unable to find explicit
activity class
{com.example.flamanco.trackme/com.firebase.ui.auth.KickoffActivity};
have you declared this activity in your AndroidManifest.xml? at
android.app.Instrumentation.checkStartActivityResult
You need to declare the activity in the AndroidManifest.xml
Open your manifest file and add the KicoffActivity.
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:installLocation="auto">
<activity
android:name="KickoffActivity"/>
</manifest>
Also, I am not sure you have initial FirebaseApp twice here..
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
FirebaseApp.initializeApp(this);
setContentView(R.layout.activity_main);
FirebaseApp.initializeApp(this);
}
Usually it should be initialized only once in the application class,
in onCreate() method.
Create a new application class..
public class YourApplicationClass extends Application {
#Override
public void onCreate() {
super.onCreate();
FirebaseApp.initializeApp(this);
}
}
And add the same in the manifest,
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:installLocation="auto">
<application
android:name="YourApplicationClass"
android:allowBackup="false"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:largeHeap="true"
android:supportsRtl="true"
android:theme="#style/MyMaterialTheme.Base">
<activity
android:name="KickoffActivity"/>
</application>
</manifest>
Manually adding the KickoffActivity activity to the manifest is not the right solution. It should be done for you.
If you manually add the KickoffActivity, you will then have to add another activity and another one and so on.
I happened to have:
tools:node="replace">
In my manifest. Which prevents any manifest merging.
Removed it and it worked fine since.
After that you might get some other merging errors like duplicate tags etc..
But the error will be different and will tell you what to do now. I had a case of a tag used twice in my and in a merged manifest so I was told to add:
tools:replace="android:label"
Which fixed that too.
Make sure your have declared your KickoffActivity properly in AndroidManifest.xml
as
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="xxx.xxx.xxx">
<application
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme">
<activity android:name=".KickoffActivity">
</activity>
</application>
</manifest>
Especially check the name attribute, if you have activity in package say "test" then
you'll have to change
the name attribute as
<activity android:name=".test.KickoffActivity">
</activity>
If everything fine with AndroidManifest.xml,
I would suggest to update your libraries as mentioned by deividas.
You can check the FirebaseUI release notes here https://github.com/firebase/FirebaseUI-Android/releases
Also update other firebase libraries to
compile 'com.google.firebase:firebase-core:11.0.4'
compile 'com.google.firebase:firebase-auth:11.0.4'
Finally I have completely reinstall android studio to latest version, updated everything including
Google play service
firebase libraries
gradle version
google repositoris
And I started new project from begining and worked with no error.
there are many activities that are added automatically on adding AUTHUI dependencies.
these activity includes kickoffactivity,recoverpasswordactivity,registerEmailActivity,etc
I can verify if by going to path
/project/module/build/intermediates/manifests/full/debug/AndroidManifest.xml.
previously i don't have kickoffactivity in this manifest file, I don't know the reason,but now i have it.I don't think adding it manually on app's manifest file will work.
Add the following in the manifest file:
< activity android :name=" *name of the activity* ">
< /activity>
The above is added by default inside the manifest, but in case if it is not, then do add it.
Related
Unable to find explicit activity class {ad97.com.ocruse/com.theartofdev.edmodo.cropper.CropImageActivity}; have you declared this activity in your AndroidManifest.xml?
Unable to find explicit activity class
{ad97.com.ocruse/com.theartofdev.edmodo.cropper.CropImageActivity};
You should add CropImageActivity into your AndroidManifest.xml
<activity android:name="com.theartofdev.edmodo.cropper.CropImageActivity"
android:theme="#style/Base.Theme.AppCompat"/>
After that,
Clean-Rebuild-Run.
Read Android Image Cropper
To use dependency and Sync.
api 'com.theartofdev.edmodo:android-image-cropper:2.8.+'
or
api 'com.theartofdev.edmodo:android-image-cropper:2.5.1'
or
api 'com.theartofdev.edmodo:android-image-cropper:2.4.1'
you have to declare CropImageActivity in Manifest file
Something like that
<application
android:name=".MyApplication">
<activity
android:name="ActivityName"/>
</application>
In your manifest file add this code
<activity android:name="com.theartofdev.edmodo.cropper.CropImageActivity"/>
you can use
jcenter()
in the gradle repositories
instead of using
mavenCentral() repositories
What I am trying to achieve:
I have created Android Plugin Project (cclib-release.aar) which has a targeted Activity.
I want to invoke this Activity in ionic2 using Cordova Plugin which has cclib-release.aar added as dependency inside Cordova Plugin. aar file added in cordova plugin as per this link
Problem facing:
While invoking Activity, I am getting the following error
java.lang.NoClassDefFoundError: Failed resolution of: Lcompute/cclib/MainActivity;
Caused by: java.lang.ClassNotFoundException: Didn't find class "compute.cclib.MainActivity" on path: DexPathList[[zip file "/data/app/com.ionicframework.fragmentwithionic759798-2/base.apk"],nativeLibraryDirectories=[/data/app/com.ionicframework.fragmentwithionic759798-2/lib/arm, /vendor/lib, /system/lib]]
The issue is similar to SO Link in which the issue was resolved.
But even after following similar step's I am getting the above mentioned error!
My Plugin Structure: (cclib-release.aar is my targeted library with Activity)
My Inject.java goes like this
public class Inject extends CordovaPlugin {
#Override
public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException {
if (action.equals("coolMethod")) {
String message = args.getString(0);
this.coolMethod(message, callbackContext);
return true;
}
return false;
}
private void coolMethod(String message, CallbackContext callbackContext) {
if (message != null && message.length() > 0) {
cordova.getActivity().runOnUiThread(new Runnable() {
public void run() {
Intent intent = new Intent(cordova.getActivity().getApplicationContext(),
compute.cclib.MainActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
cordova.getActivity().startActivity(intent);
}
});
callbackContext.success(message);
} else {
callbackContext.error("Expected one non-empty string argument.");
}
}
}
Added this plugin in ionic2 using
cordova plugin add PATH_TO_PLUGIN
As per above mentioned answer by SO, I have modified Ionic2 project's AndroidManifest.xml manually .Path =FragmentWithIonic\platforms\android to refer the Activity.
<activity android:label="#string/activity_name"
android:launchMode="singleTop" android:theme="#android:style/Theme.DeviceDefault.NoActionBar"
android:name="compute.cclib.MainActivity">
</activity>
I am invoking this in Ionic2 using below which works fine in other cases.
this.platform.ready().then(() => {
window.plugins.Inject.coolMethod(message, "short", position);
});
I tried to manually import compute.cclib.MainActivity in Inject.java. But invoking Activity is still giving run time error!
Below is the modified FragmentWithIonic\platforms\android\AndroidManifest.xml
<?xml version='1.0' encoding='utf-8'?>
<manifest android:hardwareAccelerated="true"
android:versionCode="1"
android:versionName="0.0.1"
package="com.ionicframework.fragmentwithionic759798"
xmlns:android="http://schemas.android.com/apk/res/android">
<supports-screens android:anyDensity="true"
android:largeScreens="true"
android:normalScreens="true"
android:resizeable="true"
android:smallScreens="true"
android:xlargeScreens="true" />
<application android:hardwareAccelerated="true"
android:icon="#mipmap/icon"
android:label="#string/app_name"
android:supportsRtl="true">
<activity
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale"
android:label="#string/activity_name"
android:launchMode="singleTop"
android:name="MainActivity"
android:theme="#android:style/Theme.DeviceDefault.NoActionBar"
android:windowSoftInputMode="adjustResize">
<intent-filter android:label="#string/launcher_name">
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:label="#string/activity_name"
android:launchMode="singleTop"
android:theme="#android:style/Theme.DeviceDefault.NoActionBar"
android:name="compute.cclib.MainActivity">
</activity>
</application>
<uses-sdk android:minSdkVersion="16" android:targetSdkVersion="24" />
</manifest>
What modifications I need to do to invoke Activity in my plugin?
EDIT 1
After #gmmo suggested, I included reference libraries in my Plugin's gradle File (Inject.gradle)
repositories{
jcenter()
maven { url "https://jitpack.io" }
flatDir{
dirs 'aar'
}
}
dependencies {
compile 'com.android.support:appcompat-v7:25.1.0'
compile(name:'cclib-release', ext:'aar')
}
android {
packagingOptions {
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
}
}
Now I am getting the following error while building my ionic2 project.
A problem occurred configuring root project 'android'.
> You have not accepted the license agreements of the following SDK components:
[Android Support Repository].
Before building your project, you need to accept the license agreements and complete the installation of the missing components using the Android Studio SDK Manager.
Alternatively, to learn how to transfer the license agreements from one workstation to another, go to http://d.android.com/r/studio-ui/export-licenses.html
I have already updated with all license agreements in SDK. I am pretty sure this is due to this lines in Inject.gradle
compile 'com.android.support:appcompat-v7:25.1.0'
Plugin might not able to find the corresponding dependencies
You can definitely invoke full activities inside the aar file. My aar file contained several activities. I have not seen the issue you mentioned, but I have seen path issues when the aar gradle file had problems. You may want to revise your gradle file. This is the one my plugin uses:
repositories{
jcenter()
maven { url "https://jitpack.io" }
flatDir{
dirs 'libs'
}
}
dependencies {
compile 'com.android.support:support-v13:23.1.0'
compile 'com.android.support:support-v4:23.1.0'
compile 'com.android.support:gridlayout-v7:23.1.1'
compile 'com.android.support:appcompat-v7:23.1.0'
compile 'com.android.support:design:23.1.0'
compile 'com.android.volley:volley:1.0.0'
compile 'com.google.code.gson:gson:2.4'
compile 'com.google.android.gms:play-services-base:8.1.0'
compile 'com.google.android.gms:play-services-location:8.1.0'
compile 'com.google.android.gms:play-services-maps:8.1.0'
compile 'com.google.android.gms:play-services-gcm:8.1.0'
compile 'com.github.bumptech.glide:glide:3.7.0'
compile 'com.android.support:recyclerview-v7:23.1.0'
compile 'com.android.support:cardview-v7:23.1.0'
compile 'org.altbeacon:android-beacon-library:2.+'
compile 'com.cloudinary:cloudinary-android:1.2.2'
compile(name:'mysdk', ext:'aar')
}
android {
packagingOptions {
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
}
}
and this is how I invoke activities from the cordova plugin:
#Override
public void initialize(CordovaInterface cordova, CordovaWebView webView) {
super.initialize(cordova, webView);
Logger.v(Constants.Engine.LOGGER_TAG_APP, "Plugin Initialized...");
Context context = cordova.getActivity();
// This works for me
Intent intent = new Intent(context, PermissionsActivity.class);
context.startActivity(intent);
}
and snipped of my plugin .xml
<!-- Initialization -->
<platform name="android">
<config-file target="config.xml" parent="/*">
<feature name="PlatformSDK">
<param name="android-package" value="com.mycompany.PlatformSdk.cordova.PlatformSDKCordovaPlugin" />
<param name="onload" value="true" />
</feature>
</config-file>
<framework src="libs/mysdk.gradle" custom="true" type="gradleReference" />
<resource-file src="libs/mysdk.aar" target="libs/mysdk.aar" />
<source-file src="PlatformSDKCordovaPlugin.java" target-dir="src/com/mycompany/PlatformSDK/cordova" />
</platform>
Okey finally I figure out the issue.
Ionic2 project need to update SDK tools by the following command
android update sdk --no-ui --filter extra
Got this input from cordova-plugin-issues
One more command was mentioned which I am not sure about which was the below one. If someone come across similar issue can try this out as well
android update sdk --no-ui --all --filter
A big Thanks to #gmmo , as he gave me the input to add all
dependencies also along with plugin's Inject.gradle .
As I was in an impression that why would this be required after all these dependencies was already covered in Android Plugin Project.
android.content.ActivityNotFoundException: Unable to find explicit activity class {com.newco.cooltv.qa/com.google.android.libraries.cast.companionlibrary.cast.player.VideoCastControllerActivity}; have you declared this activity in your AndroidManifest.xml?
i am using cast companion library and tried both way
(1) Add this library from jCenter repo by adding the following line to your project's dependencies:
(2) Use the GitHub source and include that as a module dependency by following these steps:
Both are failing with above exception after call to
loadRemoteMedia(mediaInfo, 0, true);
in build.gradle i have specified below dependencies
// lib for chromecast
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.android.support:mediarouter-v7:23.3.0'
compile 'com.google.android.gms:play-services-cast:9.0.2'
compile project(':CastCompanionLibrary')
I am using Andorid Studio 2.1.2 and updated build.gradle of CCL with
dependencies {
classpath 'com.android.tools.build:gradle:2.1.2'
}
Make sure you declare that in your Manifest file, something like:
<activity
android:name="com.google.android.libraries.cast.companionlibrary.cast.player.VideoCastControllerActivity"
android:label="#string/app_name"
android:launchMode="singleTask"
android:theme="#style/Theme.AppCompat.Light.NoActionBar"
android:screenOrientation="portrait" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
</intent-filter>
</activity>
i want implement facebook login in my android app but when onCreate set the layout my app crash.
MainActivity.java
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import com.facebook.CallbackManager;
import com.facebook.FacebookSdk;
import com.facebook.login.widget.LoginButton;
public class MainActivity extends AppCompatActivity {
private LoginButton facebookLoginButton;
private CallbackManager callbackManager;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
System.out.println("Prova 1");
try {
setContentView(R.layout.activity_main);
}catch(Exception exc){
System.out.println("Errore activity "+exc);
}
System.out.println("Prova 2");
FacebookSdk.sdkInitialize(this.getApplicationContext());
System.out.println("Prova 3");
}
}
Module:app build.gradle
repositories {
mavenCentral()
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.0'
compile 'com.facebook.android:facebook-android-sdk:4.7.0'
}
activity_main.xml
<com.facebook.login.widget.LoginButton
xmlns:fb="http://schemas.android.com/apk/res-auto"
android:id="#+id/login_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="30dp"
android:layout_marginBottom="30dp" />
The system print only "Prova 1" and I don't know why!
This is the manifest:
<uses-permission android:name="android.permission.INTERNET"/>
<activity
android:name="com.facebook.FacebookActivity"
android:configChanges="keyboard|keyboardHidden|screenLayout|screenSize|orientation"
android:label="#string/app_name"
android:theme="#android:style/Theme.Translucent.NoTitleBar" />
with meta-data:
<meta-data
android:name="com.facebook.sdk.ApplicationId"
android:value="#string/facebook_app_id"/>
My phone have api 19 but the application work with 15 to 23 api. I have copy this code also in other application find online login-basic where not crash.
What is my error ? It's some day that i test this but nothing, please help me!
Thank you!!
--------------------------------------------------Updating-----------------
Excuse me , I had already set the permissions for Internet. The problem is when the main build the setContentView(R.layout.activity_main); and i don't know why. In the activity_main there is only the facebook button. Also, i try this code in a new project and that's why I put everything in the main.
The catch error is: I/System.out: Errore android.view.InflateException: Binary XML file line #14: Error inflating class com.facebook.login.widget.LoginButton
I have been into same problem and the solution wan to initialize facebooksdk before calling setContentView function like this.
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
FacebookSdk.sdkInitialize(getApplicationContext());
setContentView(R.layout.activity_main);
}
As you are using facebook LoginButton which is a view so the initialization has to be made before your UI content is loaded.
First of all, i do believe you need an internet connection in order to access Facebook. However, in your manifest file you have not added the internet permission so please do as follows
<uses-permission android:name="android.permission.INTERNET" />
Secondly, it seems you are running the Facebook login process on the main thread of your app which is not a good idea. Use Async Tasks would be a better option.You can read more on them at http://developer.android.com/reference/android/os/AsyncTask.html
In addition to this, it is good practice to use "Try " and "Catch" to prevent your app from crashing completely. It usually has the following syntax
Try
//Block of Code Here
Catch Exception()
This question already has answers here:
How to use flurry in an application?
(3 answers)
Closed 8 years ago.
How can I add flurry into my android studio project, I haven't done this before, so I am not entirely sure where to add the files? I have FlurryAnalytics.jar
and how to use in my app?
thanx
Here is how I added Flurry:
Add FlurryAnalytics_3.3.2.jar (or latest) to libs folder (create this directory if necessary)
Add compile fileTree(dir: 'libs', include: '*.jar') to the dependencies in your project's build.gradle
dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
}
or Gradle + Jcenter compile 'com.flurry.android:analytics:6.2.0'
Add appropriate permissions to AndroidManifest.xml:
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
Make sure a versionName attribute is specified in AndroidManifest.xml to have data reported under that version name, such as:
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionName="1.0">
Optionally, add you Flurry API key to a constants file, such as AppConstants.java:
public class AppConstants {
public static final String FLURRY_API_KEY = "YOUR_API_KEY"; // where YOUR_API_KEY is your actual API key from FLURRY similar to 1ABCDE23EFGH4IJKLMN5O
Add the Flurry onStartSession and onEndSession to each activity in your app:
#Override
protected void onStart()
{
super.onStart();
FlurryAgent.onStartSession(this, AppConstants.FLURRY_API_KEY);
}
#Override
protected void onStop()
{
super.onStop();
FlurryAgent.onEndSession(this);
}
I still had some issues at this point and selected a hint recommended by Android Studio while viewing my build.gradle file. It changed gradle-1.8-bin.zip to gradle-1.8-bin.zip to gradle-1.8-all.zip in gradle/wrapper/gradle-wrapper.properties:
distributionUrl=http\://services.gradle.org/distributions/gradle-1.8-all.zip
After this, my project built successfully and started to log Flurry events. FYI, it takes a few hours to see the logs in Flurry.
This is a good reference for Android Studio and gradle
And of course, Flurry provided the details for much of this as well.