android send public storage file via email - android

I have looked at many, many SO posts to find an answer, but no luck...
How do I send a file from public storage as an e-mail attachment?
Most posts are asking about internal storage files. So for that, they use FileProvider (or something like that). In the docs for FileProvider, I read:
FileProvider ... facilitates secure sharing of files associated with an app...
But the file I want to send is not associated with my app. It is a .csv file in public storage in the Documents folder. So it seems really bizarre for my app to set up a FileProvider with access permissions for a public file. Even more strange to use my package name as the "authority".
I tried the following code, which I put together based on answers in 1 or 2 other posts:
File path = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOCUMENTS);
File f = new File(path, _sFileName);
_sFileDir = f.getCanonicalPath();
and in another method I have:
Intent i = new Intent(android.content.Intent.ACTION_SEND);
String Email[] = { "my.name#gmail.com" };
i.putExtra(android.content.Intent.EXTRA_EMAIL, Email);
i.putExtra(android.content.Intent.EXTRA_SUBJECT, "My Report");
i.setType("plain/text");
String sURI = "file:/" + _sFileDir;
i.putExtra(Intent.EXTRA_STREAM, Uri.parse(sURI));
startActivity(i);
This causes the app to crash with the message: "MyApp has stopped"
When I changed "file:/" to "content:/" the app no longer crashed, and the email was sent, but no file was attached.
My AndroidManifest.xml contains the following permissions:
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
Here is my LogCat from the time when I use "content:/":
07-28 17:19:22.528 27809-27809/? I/art: Late-enabling -Xcheck:jni
07-28 17:19:22.569 27809-27816/? E/art: Failed sending reply to debugger: Broken pipe
07-28 17:19:22.569 27809-27816/? I/art: Debugger is no longer active
07-28 17:19:22.569 27809-27816/? I/art: Starting a blocking GC Instrumentation
07-28 17:19:22.582 27809-27809/? W/ActivityThread: Application com.myorg.myapp is waiting for the debugger on port 8100...
07-28 17:19:22.583 27809-27809/? I/System.out: Sending WAIT chunk
07-28 17:19:24.636 27809-27816/com.myorg.myapp I/art: Debugger is active
07-28 17:19:24.785 27809-27809/com.myorg.myapp I/System.out: Debugger has connected
07-28 17:19:24.785 27809-27809/com.myorg.myapp I/System.out: waiting for debugger to settle...
07-28 17:19:24.985 27809-27809/com.myorg.myapp I/System.out: waiting for debugger to settle...
07-28 17:19:25.186 27809-27809/com.myorg.myapp I/System.out: waiting for debugger to settle...
07-28 17:19:25.386 27809-27809/com.myorg.myapp I/System.out: waiting for debugger to settle...
07-28 17:19:25.588 27809-27809/com.myorg.myapp I/System.out: waiting for debugger to settle...
07-28 17:19:25.788 27809-27809/com.myorg.myapp I/System.out: waiting for debugger to settle...
07-28 17:19:25.989 27809-27809/com.myorg.myapp I/System.out: waiting for debugger to settle...
07-28 17:19:26.189 27809-27809/com.myorg.myapp I/System.out: debugger has settled (1454)
07-28 17:19:26.408 27809-27809/com.myorg.myapp W/System: ClassLoader referenced unknown path: /data/app/com.myorg.myapp-1/lib/arm
07-28 17:19:26.444 27809-27809/com.myorg.myapp I/InstantRun: starting instant run server: is main process
07-28 17:19:26.508 27809-27816/com.myorg.myapp I/art: Starting a blocking GC Instrumentation
07-28 17:19:26.801 27809-27809/com.myorg.myapp W/art: Before Android 4.1, method android.graphics.PorterDuffColorFilter android.support.graphics.drawable.VectorDrawableCompat.updateTintFilter(android.graphics.PorterDuffColorFilter, android.content.res.ColorStateList, android.graphics.PorterDuff$Mode) would have incorrectly overridden the package-private method in android.graphics.drawable.Drawable
07-28 17:19:28.471 27809-27814/com.myorg.myapp I/art: Do partial code cache collection, code=14KB, data=23KB
07-28 17:19:28.471 27809-27814/com.myorg.myapp I/art: After code cache collection, code=14KB, data=23KB
07-28 17:19:28.471 27809-27814/com.myorg.myapp I/art: Increasing code cache capacity to 128KB
07-28 17:19:28.475 27809-27814/com.myorg.myapp I/art: Do partial code cache collection, code=14KB, data=42KB
07-28 17:19:28.476 27809-27814/com.myorg.myapp I/art: After code cache collection, code=14KB, data=42KB
07-28 17:19:28.476 27809-27814/com.myorg.myapp I/art: Increasing code cache capacity to 256KB
07-28 17:19:29.036 27809-27814/com.myorg.myapp I/art: Do full code cache collection, code=119KB, data=108KB
07-28 17:19:29.037 27809-27814/com.myorg.myapp I/art: After code cache collection, code=113KB, data=86KB
07-28 17:19:29.216 27809-27895/com.myorg.myapp I/Adreno: QUALCOMM build : 7d18700, I8ee426a9a2
Build Date : 10/07/16
OpenGL ES Shader Compiler Version: XE031.09.00.03
Local Branch : mybranch22308589
Remote Branch : quic/LA.BR.1.3.6_rb1.6
Remote Branch : NONE
Reconstruct Branch : NOTHING
07-28 17:19:29.229 27809-27895/com.myorg.myapp I/OpenGLRenderer: Initialized EGL, version 1.4
07-28 17:19:29.229 27809-27895/com.myorg.myapp D/OpenGLRenderer: Swap behavior 1
07-28 17:19:29.388 27809-27814/com.myorg.myapp I/art: Do partial code cache collection, code=125KB, data=105KB
07-28 17:19:29.388 27809-27814/com.myorg.myapp I/art: After code cache collection, code=125KB, data=105KB
07-28 17:19:29.388 27809-27814/com.myorg.myapp I/art: Increasing code cache capacity to 512KB
07-28 17:19:29.691 27809-27809/com.myorg.myapp W/art: Before Android 4.1, method int android.support.v7.widget.ListViewCompat.lookForSelectablePosition(int, boolean) would have incorrectly overridden the package-private method in android.widget.ListView
07-28 17:19:29.701 27809-27809/com.myorg.myapp I/Choreographer: Skipped 97 frames! The application may be doing too much work on its main thread.
07-28 17:19:34.479 27809-27809/com.myorg.myapp I/Choreographer: Skipped 124 frames! The application may be doing too much work on its main thread.
07-28 17:19:37.417 27809-27809/com.myorg.myapp W/IInputConnectionWrapper: reportFullscreenMode on inexistent InputConnection
07-28 17:19:37.417 27809-27809/com.myorg.myapp W/IInputConnectionWrapper: finishComposingText on inactive InputConnection
07-28 17:19:41.841 27809-27814/com.myorg.myapp I/art: Do full code cache collection, code=252KB, data=246KB
07-28 17:19:41.844 27809-27814/com.myorg.myapp I/art: After code cache collection, code=248KB, data=216KB
07-28 17:19:45.257 27809-27809/com.myorg.myapp I/Choreographer: Skipped 204 frames! The application may be doing too much work on its main thread.
07-28 17:19:49.125 27809-27809/com.myorg.myapp W/IInputConnectionWrapper: reportFullscreenMode on inexistent InputConnection
07-28 17:19:49.126 27809-27809/com.myorg.myapp W/IInputConnectionWrapper: finishComposingText on inactive InputConnection
07-28 17:19:57.498 27809-27814/com.myorg.myapp I/art: Do partial code cache collection, code=250KB, data=227KB
07-28 17:19:57.499 27809-27814/com.myorg.myapp I/art: After code cache collection, code=250KB, data=227KB
07-28 17:19:57.499 27809-27814/com.myorg.myapp I/art: Increasing code cache capacity to 1024KB
07-28 17:20:12.117 27809-27809/com.myorg.myapp W/IInputConnectionWrapper: reportFullscreenMode on inexistent InputConnection
07-28 17:20:12.117 27809-27809/com.myorg.myapp W/IInputConnectionWrapper: finishComposingText on inactive InputConnection
Here's another LogCat when "file:/" is used & the app crashes:
07-28 17:43:57.190 30651-30651/com.myorg.myapp D/AndroidRuntime: Shutting down VM
07-28 17:43:57.232 30651-30651/com.myorg.myapp E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.myorg.myapp, PID: 30651
java.lang.IllegalStateException: Could not execute method for android:onClick
at android.support.v7.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:293)
at android.view.View.performClick(View.java:5612)
at android.view.View$PerformClick.run(View.java:22285)
at android.os.Handler.handleCallback(Handler.java:751)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6123)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:757)
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Method.invoke(Native Method)
at android.support.v7.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:288)
at android.view.View.performClick(View.java:5612) 
at android.view.View$PerformClick.run(View.java:22285) 
at android.os.Handler.handleCallback(Handler.java:751) 
at android.os.Handler.dispatchMessage(Handler.java:95) 
at android.os.Looper.loop(Looper.java:154) 
at android.app.ActivityThread.main(ActivityThread.java:6123) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:757) 
Caused by: android.os.FileUriExposedException: file://storage/emulated/0/Documents/Tasks.csv exposed beyond app through ClipData.Item.getUri()
at android.os.StrictMode.onFileUriExposed(StrictMode.java:1813)
at android.net.Uri.checkFileUriExposed(Uri.java:2360)
at android.content.ClipData.prepareToLeaveProcess(ClipData.java:832)
at android.content.Intent.prepareToLeaveProcess(Intent.java:8957)
at android.content.Intent.prepareToLeaveProcess(Intent.java:8942)
at android.app.Instrumentation.execStartActivity(Instrumentation.java:1583)
at android.app.Activity.startActivityForResult(Activity.java:4228)
at android.support.v4.app.BaseFragmentActivityJB.startActivityForResult(BaseFragmentActivityJB.java:50)
at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:79)
at android.app.Activity.startActivityForResult(Activity.java:4187)
at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:859)
at android.app.Activity.startActivity(Activity.java:4515)
at android.app.Activity.startActivity(Activity.java:4483)
at com.myorg.myapp.MainActivity.onClickSend(ProgSummary.java:209)
at java.lang.reflect.Method.invoke(Native Method) 
at android.support.v7.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:288) 
at android.view.View.performClick(View.java:5612) 
at android.view.View$PerformClick.run(View.java:22285) 
at android.os.Handler.handleCallback(Handler.java:751) 
at android.os.Handler.dispatchMessage(Handler.java:95) 
at android.os.Looper.loop(Looper.java:154) 
at android.app.ActivityThread.main(ActivityThread.java:6123) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:757)
What is the right way to do this?
New Information:
When I used "content:/", this time I saw a message (Toast?) flash briefly on the Gmail app, saying "Can't attach empty file". But it's not empty!!!
More New Information:
I tried using FileProvider to do this. Here's the code...
AndroidManifest.xml:
<provider
android:name="android.support.v4.content.FileProvider"
android:authorities="com.myorg.myapp.fileprovider"
android:grantUriPermissions="true"
android:exported="false">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="#xml/filepaths" />
</provider>
filepaths.xml:
<?xml version="1.0" encoding="utf-8"?>
<paths>
<external-path name="publicdocuments/" path="documents/" />
</paths>
MainActivity.java:
public void onClickSend(View v) {
Intent i = new Intent(android.content.Intent.ACTION_SEND);
String Email[] = { "my.address#gmail.com" };
i.putExtra(android.content.Intent.EXTRA_EMAIL, Email);
i.putExtra(android.content.Intent.EXTRA_SUBJECT, "Report");
i.setType("text/plain");
File path = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOCUMENTS);
File f = new File(path, "file.csv");
Uri sUri = FileProvider.getUriForFile(MainActivity.this, "com.myorg.myapp.fileprovider", f);
i.setData(sUri);
i.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
startActivity(i);
}
The problem now is that it doesn't work - my app crashes again on the call to FileProvider.getUriForFile().
Here's the new LogCat:
--------- beginning of crash
07-29 13:45:27.116 10397-10397/com.myorg.myapp E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.myorg.myapp, PID: 10397
java.lang.IllegalStateException: Could not execute method for android:onClick
at android.support.v7.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:293)
at android.view.View.performClick(View.java:5612)
at android.view.View$PerformClick.run(View.java:22285)
at android.os.Handler.handleCallback(Handler.java:751)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6123)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:757)
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Method.invoke(Native Method)
at android.support.v7.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:288)
at android.view.View.performClick(View.java:5612) 
at android.view.View$PerformClick.run(View.java:22285) 
at android.os.Handler.handleCallback(Handler.java:751) 
at android.os.Handler.dispatchMessage(Handler.java:95) 
at android.os.Looper.loop(Looper.java:154) 
at android.app.ActivityThread.main(ActivityThread.java:6123) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:757) 
Caused by: java.lang.IllegalArgumentException: Failed to find configured root that contains /storage/emulated/0/Documents/Tasks.csv
at android.support.v4.content.FileProvider$SimplePathStrategy.getUriForFile(FileProvider.java:711)
at android.support.v4.content.FileProvider.getUriForFile(FileProvider.java:400)
at com.myorg.myapp.MainActivity.onClickSend(MainActivity.java:214)
at java.lang.reflect.Method.invoke(Native Method) 
at android.support.v7.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:288) 
at android.view.View.performClick(View.java:5612) 
at android.view.View$PerformClick.run(View.java:22285) 
at android.os.Handler.handleCallback(Handler.java:751) 
at android.os.Handler.dispatchMessage(Handler.java:95) 
at android.os.Looper.loop(Looper.java:154) 
at android.app.ActivityThread.main(ActivityThread.java:6123) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:757)
As you can see, there is an InvocationTargetException, but I don't know why...
Additional Information: Replacing MainActivity.this with v.getContext() in FileProvider.getUriForFile() gives the same result.

So it seems really bizarre for my app to set up a FileProvider with access permissions for a public file
The app that you are trying to send it through may not have external storage access. Hence, FileProvider is still the recommended pattern.
This causes the app to crash with the message: "MyApp has stopped"
Use LogCat to examine the Java stack trace associated with the crash in whatever app "MyApp" is.
Also, please note that plain/text is not a valid MIME type. Presumably you mean text/plain.
And, given a File, use Uri.fromFile() to generate a Uri for it. Bear in mind that your app may crash on Android 7.0+ for using a file scheme, though, which is another reason for using FileProvider.
What is the right way to do this?
Use FileProvider.

Related

Android - I cannot choose a method in Fragment - firebase [duplicate]

This question already has an answer here:
NullPointerException when setting TextView via ButtonClick
(1 answer)
Closed 5 years ago.
I have one activity and a few fragments. My structure looks like this:
Main Activity ->
- Menu 1 Fragment-> Daily Fragment / Weekly Fragment / Monthly Fragment / Annual Fragment
- Menu 2 Fragment -> empty
- Menu 3 Fragment -> empty
All menus are fragments.
Now I want to add values to the database (Cloud Firebase), but I can not call the method (onClick).
I did OnClickListener, and Override onClick (View v). It still does not work. What else do I need?
Daily Fragment:
public class DailyFragment extends Fragment implements
View.OnClickListener{
private static final String QUOTE_KEY = "quote";
private static final String AUTHOR_KEY = "author";
private static final String TAG= "InspiringQuote";
private DocumentReference mDocRef = FirebaseFirestore.getInstance().document("sampleData/inspirations");
#Nullable
#Override
public View onCreateView(LayoutInflater inflater, #Nullable ViewGroup container, #Nullable Bundle savedInstanceState) {
//just change the fragment_weekly
//with the fragment you want to inflate
//like if the class is DailyFragment it should have R.layout.home_fragment
//if it is WeeklyFragment it should have R.layout.fragment_weekly
//return inflater.inflate(R.layout.fragment_daily, null);
View layout = inflater.inflate(R.layout.fragment_daily, container, false);
//Dołączamy do przycisku obiekt nasłuchujący
Button saveButton = (Button)layout.findViewById(R.id.bn_save);
saveButton.setOnClickListener(this);
return layout;
}
#Override
public void onClick(View v){
switch (v.getId()) {
case R.id.bn_save:
saveQuote(v);
break;
}
}
public void saveQuote (View view){
EditText quoteView = (EditText) view.findViewById(R.id.quote);
EditText authorView = (EditText) view.findViewById(R.id.author);
String quoteText = quoteView.getText().toString();
String authorText = authorView.getText().toString();
if (quoteText.isEmpty() || authorText.isEmpty()) { return; }
Map<String, Object> dataToSave = new HashMap<String, Object>();
dataToSave.put(QUOTE_KEY, quoteText);
dataToSave.put(AUTHOR_KEY, quoteText);
mDocRef.set(dataToSave).addOnSuccessListener(new OnSuccessListener<Void>() {
#Override
public void onSuccess(Void aVoid) {
Log.d(TAG, "Dokument został zapisany!");
}
}).addOnFailureListener(new OnFailureListener() {
#Override
public void onFailure(#NonNull Exception e) {
Log.w(TAG, "Błąd, dokument nie został zapisany.", e);
}
});
}}
XML:
<TextView
android:id="#+id/tv_dzienne"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/quote"
android:layout_centerHorizontal="true"
android:layout_marginBottom="52dp"
android:text="Dzienne"
android:textAppearance="#style/Base.TextAppearance.AppCompat.Large" />
<EditText
android:id="#+id/quote"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/bn_save"
android:layout_alignParentStart="true"
android:layout_marginBottom="67dp"
android:ems="10"
android:hint="Podaj wartość"
android:inputType="textCapSentences"
android:paddingLeft="8dp"
android:paddingRight="8dp"
android:paddingTop="8dp" />
<EditText
android:id="#+id/author"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentStart="true"
android:layout_alignTop="#+id/quote"
android:layout_marginTop="51dp"
android:ems="10"
android:hint="Nazwa"
android:inputType="textPersonName"
android:paddingLeft="8dp"
android:paddingRight="8dp"
android:paddingTop="8dp" />
<Button
android:id="#+id/bn_save"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_centerVertical="true"
android:layout_marginEnd="8dp"
android:onClick="saveQuote" --> **cannot resolve symbol**
android:text="#string/save_quote" />
02-13 19:09:49.852 11587-11587/? I/zygote: Not late-enabling -Xcheck:jni (already on)
02-13 19:09:49.865 11587-11587/? W/zygote: Unexpected CPU variant for X86 using defaults: x86
02-13 19:09:50.864 11587-11587/? W/zygote: Skipping duplicate class check due to unrecognized classloader
02-13 19:09:50.867 11587-11587/? W/DynamiteModule: Local module descriptor class for com.google.firebase.auth not found.
02-13 19:09:50.871 11587-11587/? W/DynamiteModule: Local module descriptor class for com.google.firebase.auth not found.
02-13 19:09:50.875 11587-11587/? I/BiChannelGoogleApi: [FirebaseAuth: ] No Fallback module; NOT setting up for lazy initialization
02-13 19:09:50.879 11587-11607/? W/DynamiteModule: Local module descriptor class for com.google.firebase.auth not found.
02-13 19:09:50.892 11587-11610/? I/DynamiteModule: Considering local module com.google.android.gms.flags:2 and remote module com.google.android.gms.flags:0
02-13 19:09:50.892 11587-11610/? I/DynamiteModule: Selected local version of com.google.android.gms.flags
02-13 19:09:50.894 11587-11607/? I/FirebaseAuth: [FirebaseAuth:] Loading module via FirebaseOptions.
02-13 19:09:50.894 11587-11607/? I/FirebaseAuth: [FirebaseAuth:] Preparing to create service connection to gms implementation
02-13 19:09:50.894 11587-11587/? V/FA: Cancelling job. JobID: -386501406
02-13 19:09:50.895 11587-11587/? V/FA: Registered activity lifecycle callback
02-13 19:09:50.896 11587-11587/? I/FirebaseInitProvider: FirebaseApp initialization successful
02-13 19:09:50.917 11587-11613/? V/FA: Collection enabled
02-13 19:09:50.917 11587-11613/? V/FA: App package, google app id: com.example.xovin.organizerrozwojuosobistego, 1:922322846834:android:d173fbb977e9a87d
02-13 19:09:50.918 11587-11613/? I/FA: App measurement is starting up, version: 11910
02-13 19:09:50.918 11587-11613/? I/FA: To enable debug logging run: adb shell setprop log.tag.FA VERBOSE
02-13 19:09:50.918 11587-11610/? W/DynamiteModule: Local module descriptor class for com.google.android.gms.crash not found.
02-13 19:09:50.919 11587-11613/? I/FA: To enable faster debug mode event logging run:
adb shell setprop debug.firebase.analytics.app com.example.xovin.organizerrozwojuosobistego
02-13 19:09:50.919 11587-11613/? D/FA: Debug-level message logging enabled
02-13 19:09:50.922 11587-11610/? I/DynamiteModule: Considering local module com.google.android.gms.crash:0 and remote module com.google.android.gms.crash:10
02-13 19:09:50.922 11587-11610/? I/DynamiteModule: Selected remote version of com.google.android.gms.crash, version >= 10
02-13 19:09:50.925 11587-11587/? V/FA: onActivityCreated
02-13 19:09:50.974 11587-11610/? W/zygote: Skipping duplicate class check due to unrecognized classloader
02-13 19:09:50.979 11587-11613/? V/FA: Connecting to remote service
02-13 19:09:50.992 11587-11613/? V/FA: Connection attempt already in progress
02-13 19:09:50.995 11587-11610/? I/FirebaseCrashApiImpl: FirebaseCrashApiImpl created by ClassLoader ae[DexPathList[[zip file "/system/priv-app/PrebuiltGmsCore/app_chimera/m/DynamiteModulesC.apk"],nativeLibraryDirectories=[/data/user_de/0/com.google.android.gms/app_chimera/m/00000003/n/x86, /system/lib, /vendor/lib]]]
02-13 19:09:50.995 11587-11610/? I/FirebaseCrash: FirebaseCrash reporting loaded - com.google.android.gms.internal.zzdzk#963bd28
02-13 19:09:51.006 11587-11611/? I/DynamiteModule: Considering local module com.google.android.gms.flags:2 and remote module com.google.android.gms.flags:0
02-13 19:09:51.006 11587-11611/? I/DynamiteModule: Selected local version of com.google.android.gms.flags
02-13 19:09:51.012 11587-11611/? W/DynamiteModule: Local module descriptor class for com.google.android.gms.crash not found.
02-13 19:09:51.042 11587-11611/? I/FirebaseCrashApiImpl: FirebaseCrash reporting API initialized
02-13 19:09:51.042 11587-11611/? I/FirebaseCrash: FirebaseCrash reporting initialized com.google.android.gms.internal.zzdzk#963bd28
02-13 19:09:51.042 11587-11611/? D/FirebaseCrash: Firebase Analytics Listener for Firebase Crash is initialized
02-13 19:09:51.134 11587-11587/? W/linker: "/data/user_de/0/com.google.android.gms/app_extracted_libs/x86/libconscrypt_gmscore_jni.so" unused DT entry: type 0xf arg 0x91
02-13 19:09:51.135 11587-11587/? V/NativeCrypto: Registering com/google/android/gms/org/conscrypt/NativeCrypto's 276 native methods...
02-13 19:09:51.183 11587-11587/? D/NetworkSecurityConfig: No Network Security Config specified, using platform default
02-13 19:09:51.185 11587-11592/? I/zygote: Do partial code cache collection, code=28KB, data=30KB
02-13 19:09:51.185 11587-11587/? I/ProviderInstaller: Installed default security provider GmsCore_OpenSSL
02-13 19:09:51.186 11587-11592/? I/zygote: After code cache collection, code=27KB, data=30KB
02-13 19:09:51.186 11587-11592/? I/zygote: Increasing code cache capacity to 128KB
02-13 19:09:51.223 11587-11613/? V/FA: Connection attempt already in progress
02-13 19:09:51.224 11587-11613/? V/FA: Activity resumed, time: 79702594
02-13 19:09:51.239 11587-11613/? I/FA: Tag Manager is not found and thus will not be used
02-13 19:09:51.241 11587-11613/? D/FA: Logging event (FE): screen_view(_vs), Bundle[{firebase_event_origin(_o)=auto, firebase_screen_class(_sc)=MainActivity, firebase_screen_id(_si)=-3727998583761649633}]
02-13 19:09:51.243 11587-11618/? D/OpenGLRenderer: HWUI GL Pipeline
02-13 19:09:51.274 11587-11613/? V/FA: Connection attempt already in progress
02-13 19:09:51.307 11587-11592/? I/zygote: Do partial code cache collection, code=37KB, data=54KB
02-13 19:09:51.310 11587-11592/? I/zygote: After code cache collection, code=34KB, data=53KB
02-13 19:09:51.310 11587-11592/? I/zygote: Increasing code cache capacity to 256KB
02-13 19:09:51.312 11587-11592/? I/zygote: JIT allocated 71KB for compiled code of void android.widget.TextView.<init>(android.content.Context, android.util.AttributeSet, int, int)
02-13 19:09:51.312 11587-11592/? I/zygote: Compiler allocated 4MB to compile void android.widget.TextView.<init>(android.content.Context, android.util.AttributeSet, int, int)
02-13 19:09:53.367 11587-11618/com.example.xovin.organizerrozwojuosobistego I/OpenGLRenderer: Initialized EGL, version 1.4
02-13 19:09:53.367 11587-11618/com.example.xovin.organizerrozwojuosobistego D/OpenGLRenderer: Swap behavior 1
02-13 19:09:53.367 11587-11618/com.example.xovin.organizerrozwojuosobistego W/OpenGLRenderer: Failed to choose config with EGL_SWAP_BEHAVIOR_PRESERVED, retrying without...
02-13 19:09:53.367 11587-11618/com.example.xovin.organizerrozwojuosobistego D/OpenGLRenderer: Swap behavior 0
02-13 19:09:54.392 11587-11618/com.example.xovin.organizerrozwojuosobistego D/EGL_emulation: eglCreateContext: 0xa2f74f00: maj 2 min 0 rcv 2
02-13 19:09:55.204 11587-11592/com.example.xovin.organizerrozwojuosobistego I/zygote: Do full code cache collection, code=125KB, data=68KB
02-13 19:09:55.223 11587-11592/com.example.xovin.organizerrozwojuosobistego I/zygote: After code cache collection, code=102KB, data=39KB
02-13 19:09:55.400 11587-11618/com.example.xovin.organizerrozwojuosobistego D/EGL_emulation: eglMakeCurrent: 0xa2f74f00: ver 2 0 (tinfo 0x92495230)
02-13 19:09:55.428 11587-11587/com.example.xovin.organizerrozwojuosobistego I/Choreographer: Skipped 249 frames! The application may be doing too much work on its main thread.
02-13 19:09:57.664 11587-11618/com.example.xovin.organizerrozwojuosobistego D/EGL_emulation: eglMakeCurrent: 0xa2f74f00: ver 2 0 (tinfo 0x92495230)
02-13 19:09:59.755 11587-11587/com.example.xovin.organizerrozwojuosobistego I/Choreographer: Skipped 259 frames! The application may be doing too much work on its main thread.
02-13 19:09:59.755 11587-11613/com.example.xovin.organizerrozwojuosobistego D/FA: Connected to remote service
02-13 19:09:59.755 11587-11613/com.example.xovin.organizerrozwojuosobistego V/FA: Processing queued up service tasks: 4
02-13 19:09:59.922 11587-11587/com.example.xovin.organizerrozwojuosobistego W/View: dispatchProvideAutofillStructure(): not laid out, ignoring
02-13 19:09:59.928 11587-11587/com.example.xovin.organizerrozwojuosobistego I/chatty: uid=10089(u0_a89) com.example.xovin.organizerrozwojuosobistego identical 7 lines
02-13 19:09:59.928 11587-11587/com.example.xovin.organizerrozwojuosobistego W/View: dispatchProvideAutofillStructure(): not laid out, ignoring
02-13 19:09:59.935 11587-11587/com.example.xovin.organizerrozwojuosobistego I/AssistStructure: Flattened final assist data: 9104 bytes, containing 1 windows, 44 views
02-13 19:09:59.950 11587-11628/com.example.xovin.organizerrozwojuosobistego I/FirebaseCrash: Sending crashes
02-13 19:10:01.237 11587-11613/com.example.xovin.organizerrozwojuosobistego V/FA: Session started, time: 79712610
02-13 19:10:01.240 11587-11613/com.example.xovin.organizerrozwojuosobistego D/FA: Logging event (FE): session_start(_s), Bundle[{firebase_event_origin(_o)=auto, firebase_screen_class(_sc)=MainActivity, firebase_screen_id(_si)=-3727998583761649633}]
02-13 19:10:06.267 11587-11613/com.example.xovin.organizerrozwojuosobistego V/FA: Inactivity, disconnecting from the service
02-13 19:10:07.754 11587-11592/com.example.xovin.organizerrozwojuosobistego I/zygote: Do partial code cache collection, code=123KB, data=70KB
02-13 19:10:07.754 11587-11592/com.example.xovin.organizerrozwojuosobistego I/zygote: After code cache collection, code=123KB, data=70KB
02-13 19:10:07.754 11587-11592/com.example.xovin.organizerrozwojuosobistego I/zygote: Increasing code cache capacity to 512KB
02-13 19:10:26.008 11587-11592/com.example.xovin.organizerrozwojuosobistego I/zygote: Do full code cache collection, code=241KB, data=166KB
02-13 19:10:26.008 11587-11592/com.example.xovin.organizerrozwojuosobistego I/zygote: After code cache collection, code=162KB, data=105KB
02-13 19:10:31.670 11587-11587/com.example.xovin.organizerrozwojuosobistego D/AndroidRuntime: Shutting down VM
02-13 19:10:31.671 11587-11587/com.example.xovin.organizerrozwojuosobistego E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.xovin.organizerrozwojuosobistego, PID: 11587
java.lang.NullPointerException: Attempt to invoke virtual method 'android.text.Editable android.widget.EditText.getText()' on a null object reference
at com.example.xovin.organizerrozwojuosobistego.DailyFragment.saveQuote(DailyFragment.java:61)
at com.example.xovin.organizerrozwojuosobistego.DailyFragment$1.onClick(DailyFragment.java:48)
at android.view.View.performClick(View.java:6256)
at android.view.View$PerformClick.run(View.java:24701)
at android.os.Handler.handleCallback(Handler.java:789)
at android.os.Handler.dispatchMessage(Handler.java:98)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6541)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
02-13 19:10:31.671 11587-11587/com.example.xovin.organizerrozwojuosobistego E/UncaughtException: java.lang.NullPointerException: Attempt to invoke virtual method 'android.text.Editable android.widget.EditText.getText()' on a null object reference
at com.example.xovin.organizerrozwojuosobistego.DailyFragment.saveQuote(DailyFragment.java:61)
at com.example.xovin.organizerrozwojuosobistego.DailyFragment$1.onClick(DailyFragment.java:48)
at android.view.View.performClick(View.java:6256)
at android.view.View$PerformClick.run(View.java:24701)
at android.os.Handler.handleCallback(Handler.java:789)
at android.os.Handler.dispatchMessage(Handler.java:98)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6541)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
02-13 19:10:31.675 11587-11613/com.example.xovin.organizerrozwojuosobistego D/FA: Logging event (FE): app_exception(_ae), Bundle[{firebase_event_origin(_o)=crash, firebase_screen_class(_sc)=MainActivity, firebase_screen_id(_si)=-3727998583761649633, timestamp=1518549031673, fatal=1}]
02-13 19:10:31.747 11587-11613/com.example.xovin.organizerrozwojuosobistego V/FA: Connecting to remote service
02-13 19:10:31.749 11587-11613/com.example.xovin.organizerrozwojuosobistego V/FA: Recording user engagement, ms: 40528
02-13 19:10:31.752 11587-11613/com.example.xovin.organizerrozwojuosobistego D/FA: Logging event (FE): user_engagement(_e), Bundle[{firebase_event_origin(_o)=auto, engagement_time_msec(_et)=40528, firebase_screen_class(_sc)=MainActivity, firebase_screen_id(_si)=-3727998583761649633}]
02-13 19:10:31.766 11587-11613/com.example.xovin.organizerrozwojuosobistego V/FA: Connection attempt already in progress
02-13 19:10:31.902 11587-11638/com.example.xovin.organizerrozwojuosobistego I/FirebaseCrash: Sending crashes
02-13 19:10:32.501 11587-11638/com.example.xovin.organizerrozwojuosobistego I/FirebaseCrash: Response code: 200
02-13 19:10:32.503 11587-11638/com.example.xovin.organizerrozwojuosobistego I/FirebaseCrash: Report sent with crash report id: 1794c89e94000000
Button saveButton = (Button)layout.findViewById(R.id.bn_save);
saveButton.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
// do something when the corky2 is clicked
}
});
try this way since i think when you go to your fragment it changes your view so basically you are not on the right view

Firebase SDK is out of date, no ad showing

I found here Android Studio - SDK is out of date or is missing templates I need to update in my SDK tools.
I see no option for Firebase.
I followed the AdMob instructions. A 403 "unable to show ad" error showed, then I switched my ad unit type to "Banner" and used the test banner unit id "ca-app-pub-3940256099942544/6300978111".
My onCreate in main activity:
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
MobileAds.initialize(this, "my addmob id ");
mAdView = findViewById(R.id.adView);
AdRequest adRequest = new AdRequest.Builder().build();
mAdView.loadAd(adRequest);
initialiseView();
}
My layout:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:id="#+id/linearLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
</LinearLayout>
<com.google.android.gms.ads.AdView
xmlns:ads="http://schemas.android.com/apk/res-auto"
android:id="#+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_alignParentBottom="true"
ads:adSize="BANNER"
ads:adUnitId="ca-app-pub-3940256099942544/6300978111"
android:layout_below="#+id/linearLayout">
</com.google.android.gms.ads.AdView>
</RelativeLayout>
and my logs:
W/GooglePlayServicesUtil: Google Play Store is missing.
D/NetworkSecurityConfig: No Network Security Config specified, using platform default
W/GooglePlayServicesUtil: Google Play Store is missing.
W/GooglePlayServicesUtil: Google Play Store is missing.
W/GooglePlayServicesUtil: Google Play services is missing.
W/GooglePlayServicesUtil: Google Play Store is missing.
W/GooglePlayServicesUtil: Google Play Store is missing.
I/Ads: Starting ad request.
I/Ads: Use AdRequest.Builder.addTestDevice("C8DCA36186E6C4138C4E71BB102F78D2") to get test ads on this device.
W/GooglePlayServicesUtil: Google Play Store is missing.
W/GooglePlayServicesUtil: Google Play Store is missing.
W/Ads: Invoke Firebase method getInstance error.
W/Ads: The Google Mobile Ads SDK will not integrate with Firebase. Admob/Firebase integration requires the latest Firebase SDK jar, but Firebase SDK is either missing or out of date
W/GooglePlayServicesUtil: Google Play Store is missing.
W/GooglePlayServicesUtil: Google Play Store is missing.
W/System: ClassLoader referenced unknown path: /system/app/webview/lib/x86
W/art: Before Android 4.1, method double java.util.concurrent.ThreadLocalRandom.internalNextDouble(double, double) would have incorrectly overridden the package-private method in java.util.Random
W/art: Before Android 4.1, method int java.util.concurrent.ThreadLocalRandom.internalNextInt(int, int) would have incorrectly overridden the package-private method in java.util.Random
W/art: Before Android 4.1, method long java.util.concurrent.ThreadLocalRandom.internalNextLong(long, long) would have incorrectly overridden the package-private method in java.util.Random
I/WebViewFactory: Loading com.android.webview version 51.0.2704.91 (code 275509110)
I/cr_LibraryLoader: Time to load native libraries: 6 ms (timestamps 8593-8599)
I/cr_LibraryLoader: Expected native library version number "51.0.2704.91", actual native library version number "51.0.2704.91"
D/MediaPlayer: setSubtitleAnchor in MediaPlayer
D/MediaPlayer: setSubtitleAnchor in MediaPlayer
D/MediaPlayer: setSubtitleAnchor in MediaPlayer
I/art: Rejecting re-init on previously-failed class java.lang.Class<com.google.android.gms.internal.zzflm>: java.lang.NoClassDefFoundError: Failed resolution of: Landroid/support/customtabs/CustomTabsServiceConnection;
I/art: at boolean com.google.android.gms.internal.zznn.zzi(android.content.Context) ((null):-1)
I/art: at void com.google.android.gms.internal.zzabv.<init>(android.content.Context, com.google.android.gms.internal.zzabu) ((null):-1)
I/art: at java.lang.Object com.google.android.gms.internal.zzabx.call() ((null):-1)
I/art: at void com.google.android.gms.internal.zzago.run() ((null):-1)
I/art: at java.lang.Object java.util.concurrent.Executors$RunnableAdapter.call() (Executors.java:428)
I/art: at void java.util.concurrent.FutureTask.run() (FutureTask.java:237)
I/art: at void java.util.concurrent.ThreadPoolExecutor.runWorker(java.util.concurrent.ThreadPoolExecutor$Worker) (ThreadPoolExecutor.java:1133)
I/art: at void java.util.concurrent.ThreadPoolExecutor$Worker.run() (ThreadPoolExecutor.java:607)
I/art: at void java.lang.Thread.run() (Thread.java:761)
I/art: Caused by: java.lang.ClassNotFoundException: Didn't find class "android.support.customtabs.CustomTabsServiceConnection" on path: DexPathList[[zip file "/data/app/zapbear.quantumproductions.com.zappybear-2/base.apk"],nativeLibraryDirectories=[/data/app/zapbear.quantumproductions.com.zappybear-2/lib/x86, /system/lib, /vendor/lib]]
I/art: at java.lang.Class dalvik.system.BaseDexClassLoader.findClass(java.lang.String) (BaseDexClassLoader.java:56)
I/art: at java.lang.Class java.lang.ClassLoader.loadClass(java.lang.String, boolean) (ClassLoader.java:380)
I/art: at java.lang.Class java.lang.ClassLoader.loadClass(java.lang.String) (ClassLoader.java:312)
I/art: at boolean com.google.android.gms.internal.zznn.zzi(android.content.Context) ((null):-1)
I/art: at void com.google.android.gms.internal.zzabv.<init>(android.content.Context, com.google.android.gms.internal.zzabu) ((null):-1)
I/art: at java.lang.Object com.google.android.gms.internal.zzabx.call() ((null):-1)
I/art: at void com.google.android.gms.internal.zzago.run() ((null):-1)
I/art: at java.lang.Object java.util.concurrent.Executors$RunnableAdapter.call() (Executors.java:428)
I/art: at void java.util.concurrent.FutureTask.run() (FutureTask.java:237)
I/art: at void java.util.concurrent.ThreadPoolExecutor.runWorker(java.util.concurrent.ThreadPoolExecutor$Worker) (ThreadPoolExecutor.java:1133)
I/art: at void java.util.concurrent.ThreadPoolExecutor$Worker.run() (ThreadPoolExecutor.java:607)
I/art: at void java.lang.Thread.run() (Thread.java:761)
I/art: [ 11-20 01:41:39.886 2681: 2681 D/ ]
HostConnection::get() New Host Connection established 0xd9e15090, tid 2681
V/WebViewChromiumFactoryProvider: Binding Chromium to main looper Looper (main, tid 1) {f36c082}
I/cr_LibraryLoader: Expected native library version number "51.0.2704.91", actual native library version number "51.0.2704.91"
I/chromium: [INFO:library_loader_hooks.cc(143)] Chromium logging enabled: level = 0, default verbosity = 0
I/cr_BrowserStartup: Initializing chromium process, singleProcess=true
E/ApkAssets: Error while loading asset assets/natives_blob_64.bin: java.io.FileNotFoundException: assets/natives_blob_64.bin
E/ApkAssets: Error while loading asset assets/snapshot_blob_64.bin: java.io.FileNotFoundException: assets/snapshot_blob_64.bin
D/libEGL: Emulator has host GPU support, qemu.gles is set to 1.
E/libEGL: load_driver(/system/lib/egl/libGLES_emulation.so): dlopen failed: library "/system/lib/egl/libGLES_emulation.so" not found
D/libEGL: loaded /system/lib/egl/libEGL_emulation.so
D/libEGL: loaded /system/lib/egl/libGLESv1_CM_emulation.so
D/libEGL: loaded /system/lib/egl/libGLESv2_emulation.so
E/eglCodecCommon: glUtilsParamSize: unknow param 0x00008d57
W/cr_media: Requires BLUETOOTH permission
I/cr_DRP: No DRP key due to exception:java.lang.ClassNotFoundException: com.android.webview.chromium.Drp
D/cr_Ime: [InputMethodManagerWrapper.java:30] Constructor
W/cr_AwContents: onDetachedFromWindow called when already detached. Ignoring
D/cr_Ime: [InputMethodManagerWrapper.java:59] isActive: false
I/cr_Ime: ImeThread is not enabled.
E/libEGL: validate_display:99 error 3008 (EGL_BAD_DISPLAY)
I/OpenGLRenderer: Initialized EGL, version 1.4
D/OpenGLRenderer: Swap behavior 1
[ 11-20 01:41:40.059 2681: 2747 D/ ]
HostConnection::get() New Host Connection established 0xf2e305a0, tid 2747
I/VideoCapabilities: Unsupported profile 4 for video/mp4v-es
[ 11-20 01:41:40.076 2681: 2779 D/ ]
HostConnection::get() New Host Connection established 0xd54ee1b0, tid 2779
W/EGL_emulation: eglSurfaceAttrib not implemented
W/OpenGLRenderer: Failed to set EGL_SWAP_BEHAVIOR on surface 0xd9ee1e80, error=EGL_SUCCESS
V/assigned screenW: 1080.0
V/The jump force is: 21.637500000000003
E/chromium: [ERROR:gles2_cmd_decoder.cc(2167)] [GroupMarkerNotSet(crbug.com/242999)!:54DB7FD8]GL ERROR :GL_INVALID_OPERATION : BackFramebuffer::Create: <- error from previous GL command
W/cr_BindingManager: Cannot call determinedVisibility() - never saw a connection for the pid: 2681
D/cr_Ime: [InputMethodManagerWrapper.java:59] isActive: false
I/chromium: [INFO:CONSOLE(0)] "Document was loaded from Application Cache with manifest https://googleads.g.doubleclick.net/mads/static/mad/sdk/native/sdk-core-v40.appcache", source: https://googleads.g.doubleclick.net/mads/static/mad/sdk/native/sdk-core-v40.html (0)
I/chromium: [INFO:CONSOLE(0)] "Application Cache Checking event", source: https://googleads.g.doubleclick.net/mads/static/mad/sdk/native/sdk-core-v40.html (0)
I/chromium: [INFO:CONSOLE(0)] "Application Cache NoUpdate event", source: https://googleads.g.doubleclick.net/mads/static/mad/sdk/native/sdk-core-v40.html (0)
W/GooglePlayServicesUtil: Google Play services is missing.
D/cr_Ime: [InputMethodManagerWrapper.java:30] Constructor
W/cr_AwContents: onDetachedFromWindow called when already detached. Ignoring
D/cr_Ime: [InputMethodManagerWrapper.java:59] isActive: false
W/Ads: Not enough space to show ad. Needs 320x49 dp, but only has 320x0 dp.
E/chromium: [ERROR:gles2_cmd_decoder.cc(2167)] [GroupMarkerNotSet(crbug.com/242999)!:5420DED3]GL ERROR :GL_INVALID_OPERATION : BackFramebuffer::Create: <- error from previous GL command
I/cr_Ime: ImeThread is not enabled.
W/cr_BindingManager: Cannot call determinedVisibility() - never saw a connection for the pid: 2681
D/cr_Ime: [InputMethodManagerWrapper.java:59] isActive: false
W/Ads: Not enough space to show ad. Needs 320x49 dp, but only has 320x0 dp.
I/Ads: Scheduling ad refresh 60000 milliseconds from now.
D/cr_Ime: [InputMethodManagerWrapper.java:30] Constructor
W/cr_AwContents: onDetachedFromWindow called when already detached. Ignoring
D/cr_Ime: [InputMethodManagerWrapper.java:59] isActive: false
I/cr_Ime: ImeThread is not enabled.
I/Ads: Ad finished loading.
but I see no ad, just my app as usual.

shared preferences fails in android

I am fetching the username of the client via alert box in androidd
and storing it in a variable "name"
this is class for fetching the user name i have done so far
private void request_user_name() {
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle("Enter name:");
final EditText input_field = new EditText(this);
builder.setView(input_field);
builder.setPositiveButton("OK", new DialogInterface.OnClickListener()
{
#Override
public void onClick(DialogInterface dialogInterface, int i) {
String name = input_field.getText().toString();
SharedPreferences pref = getSharedPreferences("MyPrefs", Context.MODE_PRIVATE);
SharedPreferences.Editor edit = pref.edit();
edit.putString("name", name);
edit.commit();
String name = pref.getString("name", "");
name = name.trim();
if (TextUtils.isEmpty(name)){
request_user_name();
}
and i am calling the request_user_name class with
if(name.isEmpty()) {
request_user_name();
}
so that The application will not create pop up alert everytime i open this
but in the emulator it crashes when the apk is installed
emulator:nexus 6P api 25
android studio 2.3
logcat :
04-21 19:46:12.921 7369-7369/? I/art: Not late-enabling -Xcheck:jni (already on)
04-21 19:46:12.921 7369-7369/? W/art: Unexpected CPU variant for X86 using defaults: x86_64
04-21 19:46:13.235 7369-7369/app.torune_sav W/System: ClassLoader referenced unknown path: /data/app/app.torune_sav-2/lib/x86_64
04-21 19:46:13.274 7369-7369/app.torune_sav D/FirebaseApp: com.google.firebase.auth.FirebaseAuth is not linked. Skipping initialization.
04-21 19:46:13.295 7369-7369/app.torune_sav D/FirebaseApp: com.google.firebase.crash.FirebaseCrash is not linked. Skipping initialization.
04-21 19:46:13.344 7369-7369/app.torune_sav I/FA: App measurement is starting up, version: 9452
04-21 19:46:13.344 7369-7369/app.torune_sav I/FA: To enable debug logging run: adb shell setprop log.tag.FA VERBOSE
04-21 19:46:13.344 7369-7369/app.torune_sav D/FA: Debug logging enabled
04-21 19:46:13.344 7369-7369/app.torune_sav D/FA: AppMeasurement singleton hash: 75451222
04-21 19:46:13.378 7369-7369/app.torune_sav V/FA: Collection enabled
04-21 19:46:13.378 7369-7369/app.torune_sav V/FA: App package, google app id: app.torune_sav, 1:718884139232:android:90e5088fff923640
04-21 19:46:13.415 7369-7369/app.torune_sav V/FA: Registered activity lifecycle callback
04-21 19:46:13.417 7369-7369/app.torune_sav I/FirebaseInitProvider: FirebaseApp initialization successful
04-21 19:46:13.420 7369-7369/app.torune_sav I/InstantRun: starting instant run server: is main process
04-21 19:46:13.425 7369-7392/app.torune_sav V/FA: Using measurement
service 04-21 19:46:13.435 7369-7392/app.torune_sav V/FA: Connecting
to remote service 04-21 19:46:13.504 7369-7369/app.torune_sav
W/System: ClassLoader referenced unknown path:
/system/priv-app/PrebuiltGmsCore/lib/x86_64 04-21 19:46:13.505
7369-7369/app.torune_sav D/ApplicationLoaders: ignored Vulkan layer
search path
/system/priv-app/PrebuiltGmsCore/lib/x86_64:/system/fake-libs64:/system/priv-app/PrebuiltGmsCore/PrebuiltGmsCore.apk!/lib/x86_64:/system/lib64:/vendor/lib64
for namespace 0x7e277c41c0f0 04-21 19:46:13.513
7369-7369/app.torune_sav W/System: ClassLoader referenced unknown
path: 04-21 19:46:13.513 7369-7369/app.torune_sav W/System:
ClassLoader referenced unknown path:
/system/priv-app/PrebuiltGmsCore/lib/x86_64 04-21 19:46:13.514
7369-7369/app.torune_sav D/ApplicationLoaders: ignored Vulkan layer
search path
/system/priv-app/PrebuiltGmsCore/lib/x86_64:/system/fake-libs64:/system/priv-app/PrebuiltGmsCore/PrebuiltGmsCore.apk!/lib/x86_64:/system/lib64:/vendor/lib64
for namespace 0x7e277c41c160 04-21 19:46:13.523
7369-7369/app.torune_sav I/DynamiteModule: Considering local module
com.google.android.gms.firebase_database:3 and remote module
com.google.android.gms.firebase_database:5 04-21 19:46:13.523
7369-7369/app.torune_sav I/DynamiteModule: Selected remote version of
com.google.android.gms.firebase_database, version >= 5 04-21
19:46:13.526 7369-7369/app.torune_sav W/System: ClassLoader referenced
unknown path:
/data/user_de/0/com.google.android.gms/app_chimera/m/00000003/n/x86_64
04-21 19:46:13.583 7369-7369/app.torune_sav W/art: Before Android 4.1,
method android.graphics.PorterDuffColorFilter
android.support.graphics.drawable.VectorDrawableCompat.updateTintFilter(android.graphics.PorterDuffColorFilter,
android.content.res.ColorStateList, android.graphics.PorterDuff$Mode)
would have incorrectly overridden the package-private method in
android.graphics.drawable.Drawable 04-21 19:46:13.597
7369-7399/app.torune_sav D/NetworkSecurityConfig: No Network Security
Config specified, using platform default 04-21 19:46:13.608
7369-7369/app.torune_sav V/FA: onActivityCreated 04-21 19:46:13.754
7369-7369/app.torune_sav W/System: ClassLoader referenced unknown
path:
/data/user_de/0/com.google.android.gms/app_chimera/m/00000002/n/x86_64
04-21 19:46:13.764 7369-7369/app.torune_sav D/AndroidRuntime: Shutting
down VM
--------- >beginning of crash 04-21 19:46:13.765 7369-7369/app.torune_sav >E/AndroidRuntime: FATAL EXCEPTION: main
Process: >app.torune_sav, PID: 7369
java.lang.RuntimeException: Unable to start activity
ComponentInfo{app.torune_sav/app.real_time_chat.MainActivity}:
java.lang.NullPointerException: Attempt to invoke virtual method
'boolean java.lang.String.isEmpty()' on a null object reference
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2665)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2726)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1477)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6119)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method
'boolean java.lang.String.isEmpty()' on a null object reference
at app.real_time_chat.MainActivity.onCreate(MainActivity.java:125)
at android.app.Activity.performCreate(Activity.java:6679)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2618)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2726) 
at android.app.ActivityThread.-wrap12(ActivityThread.java) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1477) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:154) 
at android.app.ActivityThread.main(ActivityThread.java:6119) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
Can anyone figure out what the issue in the code ?
You should check if your String variable isn't null before calling .isEmpty() en it.
if(name == null && name.isEmpty()) {
request_user_name();
}
Or you should initialize it with a default value.

androidTestCompile runtime dependency doesn't work on android 5.0+

So I wrote an instrumental test that performs some changes in my database on my localhost server. I used just jdbc raw query, nothing special.
On Android < 5.0 instrumental tests run ok
On Android starting from 5.0 (doesn't matter if it's an emulator or real device) instrumentalTests classLoader throws java.lang.NoClassDefFoundError: com.mysql.jdbc.jdbc2.optional.MysqlDataSource. Note my tests do not even start.
I do have mysql in dependencies and I don't use proguard in debug mode that can strip it out.
If I specify mysql-connector-java as compile instead of androidTestCompile it works after android 5.0 as well. So the problem is androidTestCompile doesn't append mysql lib to instrumental environment.
Why does android 5.0 doesn't detect androidTestCompile dependency? Here's what I got:
build.gradle:
dependencies {
//...
androidTestCompile "mysql:mysql-connector-java:5.1.6"
}
androidTest/java/my.package.Mytest:
Note that I load mysql lib via Class.forName
import java.sql.*; // some java.sql imports, no mysql dependencies in imports.
#RunWith(AndroidJUnit4.class)
#LargeTest
public class LoginTest {
#Rule
public final ActivityTestRule<MainScreen> main = new ActivityTestRule<>(MainScreen.class);
#Test
public void checkLoginFlow() throws InterruptedException {
// Login/Sign up flow
assertEquals("App is not loaded", MainScreen.class, getCurrentActivity());
Connection conn = null;
PreparedStatement stmt = null;
try{
Class.forName("com.mysql.jdbc.Driver");
....
Here's the full log:
Testing started at 1:12 PM ...
01/17 13:12:50: Launching UITest
$ adb push /tmp/MyApp/app/outputs/apk/app-debug.apk /data/local/tmp/com.MyApp
$ adb shell pm install -r "/data/local/tmp/com.MyApp"
pkg: /data/local/tmp/com.MyApp
Success
$ adb push /tmp/MyApp/app/outputs/apk/app-debug-androidTest.apk /data/local/tmp/com.MyApp.test
$ adb shell pm install -r "/data/local/tmp/com.MyApp.test"
pkg: /data/local/tmp/com.MyApp.test
Success
Running tests
$ adb shell am instrument -w -r -e debug true com.MyApp.test/android.support.test.runner.AndroidJUnitRunner
Waiting for application to come online: com.MyApp | com.MyApp.test
Waiting for application to come online: com.MyApp | com.MyApp.test
Waiting for application to come online: com.MyApp | com.MyApp.test
Waiting for application to come online: com.MyApp | com.MyApp.test
Connecting to com.MyApp
I/art: Debugger is active
Connected to the target VM, address: 'localhost:8657', transport: 'socket'
I/System.out: Debugger has connected
I/System.out: waiting for debugger to settle...
I/System.out: waiting for debugger to settle...
I/System.out: waiting for debugger to settle...
I/System.out: waiting for debugger to settle...
I/System.out: waiting for debugger to settle...
I/System.out: waiting for debugger to settle...
I/System.out: waiting for debugger to settle...
I/System.out: debugger has settled (1434)
I/AndroidJUnitRunner: Debugger connected.
I/MonitoringInstrumentation: Instrumentation Started!
I/MonitoringInstrumentation: Setting context classloader to 'dalvik.system.PathClassLoader[DexPathList[[zip file "/system/framework/android.test.runner.jar", zip file "/data/app/com.MyApp.test-2/base.apk", zip file "/data/app/com.MyApp-2/base.apk"],nativeLibraryDirectories=[/data/app/com.MyApp.test-2/lib/x86_64, /data/app/com.MyApp-2/lib/x86_64, /vendor/lib64, /system/lib64]]]', Original: 'dalvik.system.PathClassLoader[DexPathList[[zip file "/system/framework/android.test.runner.jar", zip file "/data/app/com.MyApp.test-2/base.apk", zip file "/data/app/com.MyApp-2/base.apk"],nativeLibraryDirectories=[/data/app/com.MyApp.test-2/lib/x86_64, /data/app/com.MyApp-2/lib/x86_64, /vendor/lib64, /system/lib64]]]'
I/MonitoringInstrumentation: No JSBridge.
I/UsageTrackerFacilitator: Usage tracking enabled
I/TestRequestBuilder: Scanning classpath to find tests in apks [/data/app/com.MyApp.test-2/base.apk]
I/art: Rejecting re-init on previously-failed class java.lang.Class<com.mysql.jdbc.integration.c3p0.MysqlConnectionTester>
I/art: Rejecting re-init on previously-failed class java.lang.Class<com.mysql.jdbc.integration.c3p0.MysqlConnectionTester>
E/TestLoader: Could not find class: com.mysql.jdbc.integration.c3p0.MysqlConnectionTester
I/art: Rejecting re-init on previously-failed class java.lang.Class<com.mysql.jdbc.integration.jboss.ExtendedMysqlExceptionSorter>
I/art: Rejecting re-init on previously-failed class java.lang.Class<com.mysql.jdbc.integration.jboss.ExtendedMysqlExceptionSorter>
E/TestLoader: Could not find class: com.mysql.jdbc.integration.jboss.ExtendedMysqlExceptionSorter
I/art: Rejecting re-init on previously-failed class java.lang.Class<com.mysql.jdbc.integration.jboss.MysqlValidConnectionChecker>
I/art: Rejecting re-init on previously-failed class java.lang.Class<com.mysql.jdbc.integration.jboss.MysqlValidConnectionChecker>
E/TestLoader: Could not find class: com.mysql.jdbc.integration.jboss.MysqlValidConnectionChecker
I/art: Rejecting re-init on previously-failed class java.lang.Class<com.mysql.jdbc.jdbc2.optional.MysqlXAConnection>
I/art: Rejecting re-init on previously-failed class java.lang.Class<com.mysql.jdbc.jdbc2.optional.MysqlXAConnection>
I/art: Rejecting re-init on previously-failed class java.lang.Class<com.mysql.jdbc.jdbc2.optional.JDBC4MysqlXAConnection>
I/art: Rejecting re-init on previously-failed class java.lang.Class<com.mysql.jdbc.jdbc2.optional.JDBC4MysqlXAConnection>
E/TestLoader: Could not find class: com.mysql.jdbc.jdbc2.optional.JDBC4MysqlXAConnection
I/art: Rejecting re-init on previously-failed class java.lang.Class<com.mysql.jdbc.jdbc2.optional.SuspendableXAConnection>
I/art: Rejecting re-init on previously-failed class java.lang.Class<com.mysql.jdbc.jdbc2.optional.SuspendableXAConnection>
I/art: Rejecting re-init on previously-failed class java.lang.Class<com.mysql.jdbc.jdbc2.optional.JDBC4SuspendableXAConnection>
I/art: Rejecting re-init on previously-failed class java.lang.Class<com.mysql.jdbc.jdbc2.optional.JDBC4SuspendableXAConnection>
E/TestLoader: Could not find class: com.mysql.jdbc.jdbc2.optional.JDBC4SuspendableXAConnection
I/art: Rejecting re-init on previously-failed class java.lang.Class<com.mysql.jdbc.jdbc2.optional.MysqlDataSource>
I/art: Rejecting re-init on previously-failed class java.lang.Class<com.mysql.jdbc.jdbc2.optional.MysqlDataSource>
I/art: Rejecting re-init on previously-failed class java.lang.Class<com.mysql.jdbc.jdbc2.optional.MysqlConnectionPoolDataSource>
I/art: Rejecting re-init on previously-failed class java.lang.Class<com.mysql.jdbc.jdbc2.optional.MysqlConnectionPoolDataSource>
E/TestLoader: Could not find class: com.mysql.jdbc.jdbc2.optional.MysqlConnectionPoolDataSource
I/art: Rejecting re-init on previously-failed class java.lang.Class<com.mysql.jdbc.jdbc2.optional.MysqlDataSource>
--------- beginning of crash
E/AndroidRuntime: FATAL EXCEPTION: Instr: android.support.test.runner.AndroidJUnitRunner
Process: com.MyApp, PID: 4088
java.lang.NoClassDefFoundError: com.mysql.jdbc.jdbc2.optional.MysqlDataSource
at java.lang.Class.classForName(Native Method)
at java.lang.Class.forName(Class.java:324)
at android.support.test.internal.runner.TestLoader.doLoadClass(TestLoader.java:92)
at android.support.test.internal.runner.TestLoader.loadIfTest(TestLoader.java:113)
at android.support.test.internal.runner.TestRequestBuilder.loadClassesFromClassPath(TestRequestBuilder.java:801)
at android.support.test.internal.runner.TestRequestBuilder.build(TestRequestBuilder.java:747)
at android.support.test.runner.AndroidJUnitRunner.buildRequest(AndroidJUnitRunner.java:354)
at android.support.test.runner.AndroidJUnitRunner.onStart(AndroidJUnitRunner.java:260)
at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1879)
Started running tests
Test running failed: Instrumentation run failed due to 'java.lang.NoClassDefFoundError'
Tests ran to completion.

setSupportActionBar() Makes my app disfunction

For some reason when i put the line setSupportActionBar(MyToolBarVariable)... It goes on to my Genymotion Emulator.. But when it opens the app, it says :
Unfourtuanetly "AppName" has Stoped
But if i delete the setSupportActionBar() Everything works fine... Whats the problem here.. Im going to post MainActivity.java file.. If you need to see others please tell me so below. Thanks for helping!
package com.example.amanuel.zoo4;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.widget.Toolbar;
public class MainActivity extends AppCompatActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
setContentView(R.layout.activity_main);
}
}
Here is the LOGCAT When i press the app in my emulator!
04-06 02:09:02.522 652-1011/? I/ActivityManager: START u0 {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.example.amanuel.zoo4/.MainActivity (has extras)} from uid 10008 on display 0
04-06 02:09:02.721 3360-3360/? I/art: Late-enabling -Xcheck:jni
04-06 02:09:02.762 652-1021/? I/ActivityManager: Start proc 3360:com.example.amanuel.zoo4/u0a63 for activity com.example.amanuel.zoo4/.MainActivity
04-06 02:09:02.815 652-667/? W/art: Long monitor contention event with owner method=void com.android.server.am.ActivityManagerService.activityPaused(android.os.IBinder) from ActivityManagerService.java:6439 waiters=1 for 136ms
04-06 02:09:02.978 3360-3360/? W/System: ClassLoader referenced unknown path: /data/app/com.example.amanuel.zoo4-2/lib/x86
04-06 02:09:03.170 3360-3360/? D/AndroidRuntime: Shutting down VM
04-06 02:09:03.178 3360-3360/? E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.amanuel.zoo4, PID: 3360
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.amanuel.zoo4/com.example.amanuel.zoo4.MainActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.CharSequence android.support.v7.widget.Toolbar.getTitle()' on a null object reference
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2416)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
at android.app.ActivityThread.-wrap11(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.CharSequence android.support.v7.widget.Toolbar.getTitle()' on a null object reference
at android.support.v7.internal.widget.ToolbarWidgetWrapper.<init>(ToolbarWidgetWrapper.java:94)
at android.support.v7.internal.widget.ToolbarWidgetWrapper.<init>(ToolbarWidgetWrapper.java:87)
at android.support.v7.internal.app.ToolbarActionBar.<init>(ToolbarActionBar.java:77)
at android.support.v7.app.AppCompatDelegateImplV7.setSupportActionBar(AppCompatDelegateImplV7.java:198)
at android.support.v7.app.AppCompatActivity.setSupportActionBar(AppCompatActivity.java:96)
at com.example.amanuel.zoo4.MainActivity.onCreate(MainActivity.java:13)
at android.app.Activity.performCreate(Activity.java:6237)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476) 
at android.app.ActivityThread.-wrap11(ActivityThread.java) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:148) 
at android.app.ActivityThread.main(ActivityThread.java:5417) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) 
04-06 02:09:03.193 652-1021/? W/ActivityManager: Force finishing activity com.example.amanuel.zoo4/.MainActivity
04-06 02:09:03.500 652-1021/? I/WindowManager: Screenshot max retries 4 of Token{75d8954 ActivityRecord{722f0a7 u0 com.example.amanuel.zoo4/.MainActivity t42 f}} appWin=Window{450aeec u0 Starting com.example.amanuel.zoo4} drawState=1
04-06 02:09:03.514 652-652/? W/art: Long monitor contention event with owner method=void com.android.server.am.ActivityManagerService.crashApplication(com.android.server.am.ProcessRecord, android.app.ApplicationErrorReport$CrashInfo) from ActivityManagerService.java:12502 waiters=0 for 299ms
04-06 02:09:03.639 652-666/? W/art: Long monitor contention event with owner method=void com.android.server.am.ActivityManagerService.crashApplication(com.android.server.am.ProcessRecord, android.app.ApplicationErrorReport$CrashInfo) from ActivityManagerService.java:12502 waiters=1 for 216ms
04-06 02:09:03.640 652-652/? W/art: Long monitor contention event with owner method=void com.android.server.am.ActivityManagerService$UiHandler.handleMessage(android.os.Message) from ActivityManagerService.java:1397 waiters=1 for 111ms
04-06 02:09:03.814 652-1641/? I/OpenGLRenderer: Initialized EGL, version 1.4
04-06 02:09:04.021 652-666/? W/ActivityManager: Activity pause timeout for ActivityRecord{722f0a7 u0 com.example.amanuel.zoo4/.MainActivity t42 f}
04-06 02:09:04.129 652-1641/? W/EGL_emulation: eglSurfaceAttrib not implemented
04-06 02:09:04.130 652-1641/? W/OpenGLRenderer: Failed to set EGL_SWAP_BEHAVIOR on surface 0xd60610a0, error=EGL_SUCCESS
04-06 02:09:04.198 652-667/? I/Choreographer: Skipped 32 frames! The application may be doing too much work on its main thread.
04-06 02:09:04.303 652-981/? I/ActivityManager: Killing 1792:com.android.keychain/1000 (adj 15): empty for 3078s
04-06 02:09:04.763 652-668/? E/BluetoothAdapter: Bluetooth binder is null
04-06 02:09:04.825 652-667/? I/Choreographer: Skipped 37 frames! The application may be doing too much work on its main thread.
04-06 02:09:07.697 3360-3360/? I/Process: Sending signal. PID: 3360 SIG: 9
04-06 02:09:07.732 652-679/? I/ActivityManager: Process com.example.amanuel.zoo4 (pid 3360) has died
04-06 02:09:07.771 652-1641/? E/Surface: getSlotFromBufferLocked: unknown buffer: 0xde8f0df0
04-06 02:09:07.844 652-1641/? D/OpenGLRenderer: endAllStagingAnimators on 0xda3b2380 (RippleDrawable) with handle 0xdc57f670
04-06 02:09:07.852 652-652/? W/art: Long monitor contention event with owner method=void android.view.WindowManagerGlobal.removeView(android.view.View, boolean) from WindowManagerGlobal.java:349 waiters=0 for 102ms
04-06 02:09:07.854 652-1164/? W/InputMethodManagerService: Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy#bc8dc8f attribute=null, token = android.os.BinderProxy#4b639cb
04-06 02:09:08.200 652-671/? W/AppOps: Finishing op nesting under-run: uid 1000 pkg android code 24 time=0 duration=0 nesting=0
04-06 02:09:12.630 308-647/? W/AudioFlinger: write blocked for 9842 msecs, 14 delayed writes, thread 0xf1e00000
04-06 02:09:18.081 100-100/? D/Genyd: Received Set Clipboard
04-06 02:09:18.081 100-100/? D/Genymotion: Received Set Clipboard
Try putting setContentView(R.layout.activity_main); before trying to instantiate the Toolbar.

Categories

Resources