Constraint layout beta 4 - fragments don't work - java

Note 0:
At least try this code and let us know if it works for you or not. Because in theory this should work, but it doesn't
Note 1:
There is no error in this code it simply doesn't work if you are on any Constraint layout above alpha-7. However, I'm putting the logcat.
MainActivity.java:
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.support.v7.app.AppCompatActivity;
public class MainActivity extends AppCompatActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
FragmentManager mFragmentManager = getSupportFragmentManager();
FragmentTransaction mFragmentTransaction = mFragmentManager.beginTransaction();
Fragment fragment = new stupid();
mFragmentTransaction
.add(R.id.main_activity, fragment, "stupid")
.addToBackStack("stupid")
.commit();
}
}
activity_main.xml:
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/main_activity"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/colorPrimary"
android:clickable="true"
android:fitsSystemWindows="true"
tools:context=".MainActivity">
<TextView
android:text="Hi 1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
tools:layout_editor_absoluteY="13dp"
tools:layout_editor_absoluteX="18dp"
android:id="#+id/textView" />
</android.support.constraint.ConstraintLayout>
Stupid.java:
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
/**
* A simple {#link Fragment} subclass.
*/
public class stupid extends Fragment {
public stupid() {
// Required empty public constructor
}
#Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
return inflater.inflate(R.layout.fragment_stupid, container, false);
}
}
fragment_stupid.xml:
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="xxx.xxxxxxx.xxxxxxxx.xxxxxxxxxxxxx.stupid">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/hello_blank_fragment"
android:id="#+id/textView2"
tools:layout_constraintTop_creator="1"
tools:layout_constraintLeft_creator="1"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:layout_marginTop="136dp" />
</android.support.constraint.ConstraintLayout>
Log:
12-04 10:28:30.965 12609-12609/xxx.xxxxxxx.xxxxxxxx.xxxxxxxxxxxxx I/art: Late-enabling -Xcheck:jni
12-04 10:28:31.015 12609-12609/xxx.xxxxxxx.xxxxxxxx.xxxxxxxxxxxxx I/InstantRun: Instant Run Runtime started. Android package is xxx.xxxxxxx.xxxxxxxx.xxxxxxxxxxxxx, real application class is null.
12-04 10:28:31.299 12609-12609/xxx.xxxxxxx.xxxxxxxx.xxxxxxxxxxxxx W/art: Failed to find OatDexFile for DexFile /data/data/xxx.xxxxxxx.xxxxxxxx.xxxxxxxxxxxxx/files/instant-run/dex/slice-slice_1-classes.dex ( canonical path /data/data/xxx.xxxxxxx.xxxxxxxx.xxxxxxxxxxxxx/files/instant-run/dex/slice-slice_1-classes.dex) with checksum 0xe09cbad0 in OatFile /data/data/xxx.xxxxxxx.xxxxxxxx.xxxxxxxxxxxxx/cache/slice-slice_1-classes.dex
12-04 10:28:31.512 12609-12609/xxx.xxxxxxx.xxxxxxxx.xxxxxxxxxxxxx I/LoadedApk: No resource references to update in package common
12-04 10:28:31.512 12609-12609/xxx.xxxxxxx.xxxxxxxx.xxxxxxxxxxxxx I/LoadedApk: No resource references to update in package com.brit.swiftdark
12-04 10:28:31.809 12609-12609/xxx.xxxxxxx.xxxxxxxx.xxxxxxxxxxxxx W/ResourceType: For resource 0x01030224, entry index(548) is beyond type entryCount(29)
12-04 10:28:31.809 12609-12609/xxx.xxxxxxx.xxxxxxxx.xxxxxxxxxxxxx W/ResourceType: For resource 0x01030224, entry index(548) is beyond type entryCount(29)
12-04 10:28:31.843 12609-12609/xxx.xxxxxxx.xxxxxxxx.xxxxxxxxxxxxx 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
12-04 10:28:31.947 12609-12726/xxx.xxxxxxx.xxxxxxxx.xxxxxxxxxxxxx D/OpenGLRenderer: Use EGL_SWAP_BEHAVIOR_PRESERVED: true
12-04 10:28:31.956 12609-12609/xxx.xxxxxxx.xxxxxxxx.xxxxxxxxxxxxx D/Atlas: Validating map...
12-04 10:28:31.996 12609-12726/xxx.xxxxxxx.xxxxxxxx.xxxxxxxxxxxxx I/Adreno: QUALCOMM build : 065751b,
Build Date : 04/15/15
OpenGL ES Shader Compiler Version: E031.25.03.07
Local Branch :
Remote Branch : quic/LA.BF64.1.2.1_rb2.9
Remote Branch : NONE
Reconstruct Branch : AU_LINUX_ANDROID_LA.BF64.1.2.1_RB2.05.01.00.081.016 + 065751b + NOTHING
12-04 10:28:32.003 12609-12726/xxx.xxxxxxx.xxxxxxxx.xxxxxxxxxxxxx I/OpenGLRenderer: Initialized EGL, version 1.4
12-04 10:28:32.011 12609-12726/xxx.xxxxxxx.xxxxxxxx.xxxxxxxxxxxxx D/OpenGLRenderer: Enabling debug mode 0
12-04 10:28:32.069 12609-12609/xxx.xxxxxxx.xxxxxxxx.xxxxxxxxxxxxx I/Timeline: Timeline: Activity_idle id: android.os.BinderProxy#22f2f04f time:200835125
Edit 1:
Alpha-7
Beta-4

Please refer to this post for an answer .... ConstraintLayout 1.0.2 shows nothing
I know this is both "This post and the linked post" are mine, also the answer. But I been looking for an answer for almost a year. I finally found that older versions of ConstraintLayout will, for some reason, be added on top of the activity. Newer versions of ConstraintLayout fragment will be put in back of the activity. or at least that's what it looks to me. That's why I'm saying make your activity transparent.

Related

Problem in opening an Activity from Fragment Activity

I have created a Fragment view in my Navigation Drawer and
I want to call an Activity from that Fragment view using an ImageView for that I have written this java code in My Fragment View class
But I don't know why whenever I click on my image the app gets crashed please help out
package com.example.gamesense.ui.Maps;
import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.LinearLayout;
import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import androidx.lifecycle.ViewModelProvider;
import com.example.gamesense.R;
public class MapsFragment extends Fragment {
private MapsViewModel mapsViewModel;
private ImageView erangle_image;
public View onCreateView(#NonNull LayoutInflater inflater,
ViewGroup container, Bundle savedInstanceState) {
mapsViewModel =
new ViewModelProvider(this).get(MapsViewModel.class);
View root = inflater.inflate(R.layout.fragment_maps, container, false);
//on click listener for image
erangle_image = root.findViewById(R.id.erangle_image);
erangle_image.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
startActivity(new Intent(getActivity(),ErangleMap.class));
}
});
return root;
}
}
And here is the XML for Fragment View and
from ImageView I want to open new Activity
<?xml version="1.0" encoding="utf-8"?>
<androidx.appcompat.widget.LinearLayoutCompat xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="20dp"
android:paddingTop="20dp"
android:paddingEnd="20dp"
android:background="#drawable/background"
android:paddingBottom="20dp"
android:paddingStart="20dp"
android:paddingRight="20dp"
android:orientation="vertical"
tools:context=".ui.Maps.MapsFragment">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:id="#+id/erangle"
android:background="#drawable/shape">
<ImageView
android:layout_width="fill_parent"
android:layout_height="200dp"
android:scaleType="fitXY"
android:id="#+id/erangle_image"
android:src="#drawable/erangel"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="ERANGLE:"
android:textAlignment="viewStart"
android:background="#C59507"
android:textSize="24sp"
android:textColor="#FFFFFF"
android:paddingTop="7dp"
android:paddingLeft="15dp"
android:textStyle="bold" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#C59507"
android:paddingBottom="10dp"
android:text="Erangel is the first 8x8 km playable map created for PUBG."
android:textAlignment="textStart"
android:paddingLeft="15dp"
android:textColor="#FFFFFF"
android:textSize="18sp" />
</LinearLayout>
</androidx.appcompat.widget.LinearLayoutCompat>
Logcat
2021-03-23 09:48:47.556 10047-10047/com.example.gamesense E/Parcel: Reading a NULL string not supported here.
2021-03-23 09:48:47.586 10047-10086/com.example.gamesense E/libEGL: Invalid file path for libcolorx-loader.so
2021-03-23 09:48:47.596 10047-10047/com.example.gamesense D/AndroidRuntime: Shutting down VM
2021-03-23 09:48:47.597 10047-10047/com.example.gamesense E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.gamesense, PID: 10047
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.gamesense/com.example.gamesense.ui.Maps.ErangleMap}: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3699)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3866)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:85)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:140)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:100)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2289)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:254)
at android.app.ActivityThread.main(ActivityThread.java:8202)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:612)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1006)
Caused by: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
at androidx.appcompat.app.AppCompatDelegateImpl.createSubDecor(AppCompatDelegateImpl.java:843)
at androidx.appcompat.app.AppCompatDelegateImpl.ensureSubDecor(AppCompatDelegateImpl.java:806)
at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:693)
at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:170)
at com.example.gamesense.ui.Maps.ErangleMap.onCreate(ErangleMap.java:14)
at android.app.Activity.performCreate(Activity.java:8146)
at android.app.Activity.performCreate(Activity.java:8130)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1310)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3668)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3866) 
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:85) 
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:140) 
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:100) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2289) 
at android.os.Handler.dispatchMessage(Handler.java:106) 
at android.os.Looper.loop(Looper.java:254) 
at android.app.ActivityThread.main(ActivityThread.java:8202) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:612) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1006) 
2021-03-23 09:48:47.623 10047-10047/com.example.gamesense I/Process: Sending signal. PID: 10047 SIG: 92021-03-23 09:48:47.556 10047-10047/com.example.gamesense E/Parcel: Reading a NULL string not supported here.
2021-03-23 09:48:47.586 10047-10086/com.example.gamesense E/libEGL: Invalid file path for libcolorx-loader.so
2021-03-23 09:48:47.596 10047-10047/com.example.gamesense D/AndroidRuntime: Shutting down VM
2021-03-23 09:48:47.597 10047-10047/com.example.gamesense E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.gamesense, PID: 10047
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.gamesense/com.example.gamesense.ui.Maps.ErangleMap}: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3699)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3866)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:85)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:140)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:100)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2289)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:254)
at android.app.ActivityThread.main(ActivityThread.java:8202)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:612)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1006)
Caused by: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
at androidx.appcompat.app.AppCompatDelegateImpl.createSubDecor(AppCompatDelegateImpl.java:843)
at androidx.appcompat.app.AppCompatDelegateImpl.ensureSubDecor(AppCompatDelegateImpl.java:806)
at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:693)
at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:170)
at com.example.gamesense.ui.Maps.ErangleMap.onCreate(ErangleMap.java:14)
at android.app.Activity.performCreate(Activity.java:8146)
at android.app.Activity.performCreate(Activity.java:8130)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1310)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3668)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3866) 
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:85) 
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:140) 
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:100) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2289) 
at android.os.Handler.dispatchMessage(Handler.java:106) 
at android.os.Looper.loop(Looper.java:254) 
at android.app.ActivityThread.main(ActivityThread.java:8202) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:612) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1006) 
2021-03-23 09:48:47.623 10047-10047/com.example.gamesense I/Process: Sending signal. PID: 10047 SIG: 9```
it says "You need to use a Theme.AppCompat theme (or descendant) with this activity."
maybe you edited/removed the theme by mistake. check your manifest
have you declared this activity in your AndroidManifest.xml? check this one Check your manifest first and declare your activity
Add or modify existing theme with AppCompat theme in your styles.xml. like the following:
<style name="yourThemeName" parent="#style/Theme.AppCompat....">
//.... items will go here
</style>
And you can use this theme as global theme
<application
android:theme="#style/yourThemeName">
OR
For specific activity
<activity
android:name=".ErangleMap"
android:theme="#style/yourThemeName">
//....
</activity>

AndroidStudio - two identical (same sourcecode) apps - one works, second doesnt - app closes after starting

after setting up a new development environment and just wanted to get started, I have two simple Android Apps with just an easy, normal ImageView. They have both the same sourcecode (title is different) and amazingly the first one works, the second doesnt.
The second app gets closed instantly after beeing started. The first one works and shows the image.
As the problem I could identify the ImageView, if I delete the element, the app is starting fine.
Maybe someone can give me a tip or can help. Thank you very much!
AndroidStudio 3.6 -
Device for testing: Huawei Android 6.0
MainActivity.java:
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
public class MainActivity extends AppCompatActivity {
public void fade (View view){
ImageView imageView = findViewById(R.id.imageView);
imageView.animate().alpha(0).setDuration(2000);
}
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
}
activity_main.xml:
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<ImageView
android:id="#+id/imageView"
android:layout_width="0dp"
android:layout_height="0dp"
android:onClick="fade"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="#drawable/bart" />
</androidx.constraintlayout.widget.ConstraintLayout>
Logcat:
05-12 23:29:44.274 14433-14433/? I/art: Late-enabling -Xcheck:jni
05-12 23:29:44.356 14433-14450/com.example.testdrei E/HAL: load: id=gralloc != hmi->id=gralloc
05-12 23:29:44.373 14433-14433/com.example.testdrei W/System: ClassLoader referenced unknown path: /data/app/com.example.testdrei-2/lib/arm64
05-12 23:29:44.401 14433-14433/com.example.testdrei I/HwCust: Constructor found for class android.app.HwCustHwWallpaperManagerImpl
05-12 23:29:44.412 14433-14433/com.example.testdrei W/art: Before Android 4.1, method android.graphics.PorterDuffColorFilter androidx.vectordrawable.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
05-12 23:29:44.477 14433-14433/com.example.testdrei I/art: Rejecting re-init on previously-failed class java.lang.Class<androidx.core.view.ViewCompat$2>
05-12 23:29:44.477 14433-14433/com.example.testdrei I/art: Rejecting re-init on previously-failed class java.lang.Class<androidx.core.view.ViewCompat$2>
05-12 23:29:44.559 14433-14433/com.example.testdrei W/ResourceType: Failure getting entry for 0x7f060061 (t=5 e=97) (error -75)
05-12 23:29:44.559 14433-14433/com.example.testdrei W/ResourceType: Failure getting entry for 0x7f060061 (t=5 e=97) (error -75)
05-12 23:29:44.592 14433-14433/com.example.testdrei I/Process: Sending signal. PID: 14433 SIG: 9
The ImageView with ID R.id.imageView3 is not a part of your layout. So the below line will cause an exception
ImageView imageView = findViewById(R.id.imageView3);
Change it with the correct ID
ImageView imageView = findViewById(R.id.imageView);
Try this first and lets see if the error is coming from the xml file
<ImageView
android:id="#+id/imageView"
android:layout_width="0dp"
android:layout_height="0dp"
app:srcCompat="#drawable/bart" />

How to view missing buttons even after constraints have been applied?

I have been trying to connect to parse server and amazon web services to create a login database.
Currently, I have connected the server and the amazon web services. However, now when I add the buttons for the login details and after writing the associated code, the buttons does not show when the app is running even after I have applied constraints.
This file has been downloaded by a Udemy course that I am currently doing. The file is an old file and I had several errors that I had to fix with regards to gradle files, missing toolboxes etc.
in my Logcat, I get the following information
2019-07-20 22:33:21.627 15940-15940/? D/libEGL: Emulator has host GPU support, qemu.gles is set to 1.
2019-07-20 22:33:21.630 15940-15940/? D/libEGL: loaded /vendor/lib/egl/libEGL_emulation.so
2019-07-20 22:33:21.630 15940-15940/? D/libEGL: loaded /vendor/lib/egl/libGLESv1_CM_emulation.so
2019-07-20 22:33:21.668 15940-15940/? D/libEGL: loaded /vendor/lib/egl/libGLESv2_emulation.so
2019-07-20 23:23:22.364 15940-15940/? I/m.parse.starte: Not late-enabling -Xcheck:jni (already on)
2019-07-20 23:23:22.387 15940-15940/? E/m.parse.starte: Unknown bits set in runtime_flags: 0x8000
2019-07-20 23:23:22.388 15940-15940/? W/m.parse.starte: Unexpected CPU variant for X86 using defaults: x86
2019-07-20 23:23:22.516 15940-15940/com.parse.starter I/m.parse.starte: The ClassLoaderContext is a special shared library.
2019-07-20 23:23:22.799 15940-15940/com.parse.starter W/m.parse.starte: JIT profile information will not be recorded: profile file does not exits.
2019-07-20 23:23:22.800 15940-15940/com.parse.starter I/chatty: uid=10136(com.parse.starter) identical 10 lines
2019-07-20 23:23:22.800 15940-15940/com.parse.starter W/m.parse.starte: JIT profile information will not be recorded: profile file does not exits.
2019-07-20 23:23:22.836 15940-15940/com.parse.starter I/FirebaseInitProvider: FirebaseApp initialization unsuccessful
2019-07-20 23:23:22.839 15940-15940/com.parse.starter I/InstantRun: starting instant run server: is main process
2019-07-20 23:23:23.155 15940-15940/com.parse.starter W/m.parse.starte: Accessing hidden method Landroid/view/View;->computeFitSystemWindows(Landroid/graphics/Rect;Landroid/graphics/Rect;)Z (greylist, reflection, allowed)
2019-07-20 23:23:23.155 15940-15940/com.parse.starter W/m.parse.starte: Accessing hidden method Landroid/view/ViewGroup;->makeOptionalFitsSystemWindows()V (greylist, reflection, allowed)
2019-07-20 23:23:23.232 15940-17541/com.parse.starter D/NetworkSecurityConfig: No Network Security Config specified, using platform default
2019-07-20 23:23:23.308 15940-17536/com.parse.starter D/OpenGLRenderer: Swap behavior 1
2019-07-20 23:23:23.309 15940-17536/com.parse.starter W/OpenGLRenderer: Failed to choose config with EGL_SWAP_BEHAVIOR_PRESERVED, retrying without...
2019-07-20 23:23:23.309 15940-17536/com.parse.starter D/OpenGLRenderer: Swap behavior 0
2019-07-20 23:23:23.317 15940-17536/com.parse.starter D/eglCodecCommon: setVertexArrayObject: set vao to 0 (0) 0 0
2019-07-20 23:23:23.317 15940-17536/com.parse.starter D/EGL_emulation: eglCreateContext: 0xeb87fdc0: maj 3 min 0 rcv 3
2019-07-20 23:23:23.335 15940-17536/com.parse.starter D/EGL_emulation: eglMakeCurrent: 0xeb87fdc0: ver 3 0 (tinfo 0xe07b4540)
2019-07-20 23:23:23.391 15940-17536/com.parse.starter W/Gralloc3: mapper 3.x is not supported
2019-07-20 23:23:23.418 15940-17536/com.parse.starter D/OpenGLRenderer: Setting buffer count to 3, min_undequeued 1, extraBuffers 0
2019-07-20 23:23:23.442 15940-17536/com.parse.starter D/EGL_emulation: eglMakeCurrent: 0xeb87fdc0: ver 3 0 (tinfo 0xe07b4540)
2019-07-20 23:23:23.446 15940-17536/com.parse.starter D/eglCodecCommon: setVertexArrayObject: set vao to 0 (0) 1 0
my sdk information in the build.gradle file is:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
defaultConfig {
applicationId "com.parse.starter"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 1
versionName "1.0"
multiDexEnabled true
}
dexOptions {
javaMaxHeapSize "4g"
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation 'com.android.support:appcompat-v7:23.0.0'
implementation 'com.parse.bolts:bolts-tasks:1.3.0'
implementation 'com.parse:parse-android:1.13.0'
implementation 'com.google.android.gms:play-services:9.4.0'
implementation 'com.android.support:multidex:1.0.0'
// androidTestImplementation 'com.android.support.test:runner:1.0.2'
//androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}
and my build.gradle for the project is:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
mavenCentral()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.4.2'
}
}
allprojects {
repositories {
mavenCentral()
google()
}
}
ext {
compileSdkVersion = 22
buildToolsVersion = "23.0.1"
minSdkVersion = 9
targetSdkVersion = 23
}
my acitivity__main.xml code is :
<!--
~ Copyright (c) 2015-present, Parse, LLC.
~ All rights reserved.
~
~ This source code is licensed under the BSD-style license found in the
~ LICENSE file in the root directory of this source tree. An additional grant
~ of patent rights can be found in the PATENTS file in the same directory.
-->
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingBottom="#dimen/activity_vertical_margin"
tools:context=".MainActivity">
<Button
android:id="#+id/signUpButton"
android:layout_width="138dp"
android:layout_height="101dp"
android:layout_alignParentStart="true"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true"
android:layout_marginStart="145dp"
android:layout_marginLeft="145dp"
android:layout_marginTop="581dp"
android:layout_marginEnd="144dp"
android:layout_marginRight="144dp"
android:layout_marginBottom="64dp"
android:text="SIGN UP"
android:visibility="visible"
tools:visibility="visible" />
<EditText
android:id="#+id/usernameEditText"
android:layout_width="302dp"
android:layout_height="99dp"
android:layout_alignParentStart="true"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_alignParentBottom="true"
android:layout_marginStart="36dp"
android:layout_marginLeft="36dp"
android:layout_marginTop="240dp"
android:layout_marginBottom="376dp"
android:ems="10"
android:hint="Username"
android:inputType="textPersonName"
android:visibility="visible"
tools:visibility="visible" />
<EditText
android:id="#+id/passwordEditText"
android:layout_width="match_parent"
android:layout_height="124dp"
android:layout_alignParentStart="true"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true"
android:layout_marginStart="33dp"
android:layout_marginLeft="33dp"
android:layout_marginTop="354dp"
android:layout_marginEnd="35dp"
android:layout_marginRight="35dp"
android:layout_marginBottom="268dp"
android:ems="10"
android:hint="Password"
android:inputType="textPersonName"
android:visibility="visible"
tools:visibility="visible" />
</RelativeLayout>
so I should be able to view the buttons and Editboxes that I have created but they don't show when I run the application.
This is MainActivity.java
/*
* Copyright (c) 2015-present, Parse, LLC.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
package com.parse.starter;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.View;
import android.widget.EditText;
import android.widget.Switch;
import android.widget.Toast;
import com.parse.GetCallback;
import com.parse.LogInCallback;
import com.parse.Parse;
import com.parse.ParseAnalytics;
import com.parse.ParseAnonymousUtils;
import com.parse.ParseException;
import com.parse.ParseObject;
import com.parse.ParseQuery;
import com.parse.ParseUser;
import com.parse.SaveCallback;
import com.parse.SignUpCallback;
public class MainActivity extends AppCompatActivity {
public void signUpClicked(View view){
EditText usernameEditText = (EditText) findViewById(R.id.usernameEditText);
EditText passwordEditText = (EditText) findViewById(R.id.passwordEditText);
if (usernameEditText.getText().toString() == "" || passwordEditText.getText().toString() == ""){
Toast.makeText(this, "A username and password are required", Toast.LENGTH_LONG).show();
} else {
ParseUser user = new ParseUser();
user.setUsername(usernameEditText.getText().toString());
user.setPassword(passwordEditText.getText().toString());
user.signUpInBackground(new SignUpCallback() {
#Override
public void done(ParseException e) {
if (e==null){
//things are good and works
Log.i("Sign up", "scucess");
}else{
Toast.makeText(MainActivity.this,e.getMessage(),Toast.LENGTH_SHORT).show();
}
}
});
}
}
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ParseAnalytics.trackAppOpenedInBackground(getIntent());
}
}

android app crashes when redirecting to new activity

I am totally new with android, i created an app with basic activity and then added a button to direct to another activity, it worked but whenever i click the button to go to the new activity page the app get crashed
am getting the following error:
10/02 15:22:04: Launching app
$ adb push C:\Users\Ahmed\AndroidStudioProjects\Shiftind\app\build\outputs\apk\app-debug.apk /data/local/tmp/com.shiftind.www.shiftind
$ adb shell pm install -r "/data/local/tmp/com.shiftind.www.shiftind"
Success
$ adb shell am start -n "com.shiftind.www.shiftind/com.shiftind.www.shiftind.MainActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER
Client not ready yet..Waiting for process to come online
Connected to process 2284 on device emulator-5554
W/System: ClassLoader referenced unknown path: /data/app/com.shiftind.www.shiftind-2/lib/x86
I/InstantRun: Instant Run Runtime started. Android package is com.shiftind.www.shiftind, real application class is null.
W/System: ClassLoader referenced unknown path: /data/app/com.shiftind.www.shiftind-2/lib/x86
W/art: Verification of android.support.v4.media.session.MediaControllerCompat android.support.v4.app.FragmentActivity.getSupportMediaController() took 420.734ms
W/art: Verification of void android.support.v4.app.FragmentActivity.requestPermissionsFromFragment(android.support.v4.app.Fragment, java.lang.String[], int) took 107.527ms
W/art: Verification of void android.support.v4.app.FragmentActivity.setEnterSharedElementCallback(android.support.v4.app.SharedElementCallback) took 102.953ms
W/art: Verification of void android.support.v7.app.AppCompatActivity.onSupportActionModeFinished(android.support.v7.view.ActionMode) took 192.620ms
W/art: Verification of void android.support.v4.app.FragmentManagerImpl.setHWLayerAnimListenerIfAlpha(android.view.View, android.view.animation.Animation) took 130.794ms
W/art: Verification of android.support.v7.app.AppCompatDelegate android.support.v7.app.AppCompatDelegate.create(android.content.Context, android.view.Window, android.support.v7.app.AppCompatCallback) took 147.296ms
W/art: Verification of void android.support.v7.app.AppCompatDelegateImplBase.<init>(android.content.Context, android.view.Window, android.support.v7.app.AppCompatCallback) took 138.730ms
W/art: Verification of void android.support.v7.app.AppCompatDelegateImplV9.ensureSubDecor() took 166.867ms
W/art: Verification of void android.support.v7.app.AppCompatDelegateImplV9.onConfigurationChanged(android.content.res.Configuration) took 215.247ms
W/art: Verification of android.support.v7.view.ActionMode android.support.v7.app.AppCompatDelegateImplV9.startSupportActionModeFromWindow(android.support.v7.view.ActionMode$Callback) took 113.775ms
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
W/gralloc_ranchu: Gralloc pipe failed
[ 10-02 15:22:33.523 2284: 2284 D/ ]
HostConnection::get() New Host Connection established 0xa72c2540, tid 2284
I/OpenGLRenderer: Initialized EGL, version 1.4
D/OpenGLRenderer: Swap behavior 1
I/Choreographer: Skipped 40 frames! The application may be doing too much work on its main thread.
D/AndroidRuntime: Shutting down VM
--------- beginning of crash
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.shiftind.www.shiftind, PID: 2284
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:5610)
at android.view.View$PerformClick.run(View.java:22260)
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:6077)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:865)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)
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:5610) 
at android.view.View$PerformClick.run(View.java:22260) 
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:6077) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:865) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755) 
Caused by: android.content.ActivityNotFoundException: Unable to find explicit activity class {com.shiftind.www.shiftind/com.shiftind.www.shiftind.registration}; have you declared this activity in your AndroidManifest.xml?
at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1805)
at android.app.Instrumentation.execStartActivity(Instrumentation.java:1523)
at android.app.Activity.startActivityForResult(Activity.java:4224)
at android.support.v4.app.BaseFragmentActivityJB.startActivityForResult(BaseFragmentActivityJB.java:48)
at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:75)
at android.app.Activity.startActivityForResult(Activity.java:4183)
at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:856)
at android.app.Activity.startActivity(Activity.java:4507)
at android.app.Activity.startActivity(Activity.java:4475)
at com.shiftind.www.shiftind.MainActivity.onButtonClick(MainActivity.java:19)
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:5610) 
at android.view.View$PerformClick.run(View.java:22260) 
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:6077) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:865) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755) 
Application terminated.
my mainActivity.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/activity_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
android:paddingBottom="#dimen/activity_vertical_margin"
tools:context="com.shiftind.www.shiftind.MainActivity">
<Button
android:text="Let's Get Started"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/startbutton"
style="#style/Widget.AppCompat.Button.Colored"
android:onClick="onButtonClick"
android:layout_alignParentStart="true"
android:layout_marginStart="85dp" />
</RelativeLayout>
my registartion.xml (second activity)
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:text="registration activity"
android:layout_width="wrap_content"
android:layout_height="111dp"
android:id="#+id/textView3"
android:layout_weight="1"
android:textStyle="normal|bold" />
</LinearLayout>
my registration.java
package com.shiftind.www.shiftind;
import android.app.Activity;
import android.os.Bundle;
/**
* Created by Ahmed on 10/2/2016.
*/
public class registration extends Activity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.registration);
}
}
my main activity.java
package com.shiftind.www.shiftind;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.content.Intent;
public class MainActivity extends AppCompatActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
public void onButtonClick(View view) {
if (view.getId() == R.id.startbutton) {
Intent i = new Intent(MainActivity.this, registration.class);
startActivity(i);
}
}
}
Declare the second Activity in your manifest file and you should be sorted out
Also your button is not declared
Add this line inside <application> tag
<activity android:name=".registration" ></activity>
hope it helps

Unable to call the fragment with imageView in android

Today is my first time to be using the fragments. And I was able to make a simple app that utilizes the fragment, however, there is one problem that I cannot understand or hadn't noticed yet. The problem is the app crashes when I add the fragment with the imageView. Everything works fine when I use simple texts or other widgets. I've set the sample code below.
I'm calling the fragment from Activity1 like this.
android.support.v4.app.FragmentManager fragmentManager2 = getSupportFragmentManager();
android.support.v4.app.FragmentTransaction fragmentTransaction2 = fragmentManager2.beginTransaction();
TestFragment fragment = new TestFragment();
fragmentTransaction2.add(R.id.fragment_container, fragment,"HELLO");
fragmentTransaction2.commit();
This is the layout that fills the fragment
<LinearLayout
android:id="#+id/fragment_container"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
>
</LinearLayout>
This is the simple Activity2 class that extends the fragment
public class Activity2 extends Fragment {
#Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
/** Inflating the layout for this fragment **/
View v = inflater.inflate(R.layout.fragment_class2, null);
return v;
}
}
this is the layout for the class that extends the fragment .
Ps: The imageview in here causes the error, however, the settings in the fragment class may be the problem. I need to display the imageView.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<ImageView
android:layout_width="50dp"
android:layout_height="50dp"
android:id="#+id/imaew2"
android:src="#drawable/playimage2"
/>
</LinearLayout>
These are the error I get and I'm not sure how these errors mean, however the error is pointing to the Fragment
         
 
 at com.trymeagain.Activity2.onCreateView(Activity2.java:13)
            at android.support.v4.app.Fragment.performCreateView(Fragment.java:1789)
            at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:955)
            at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1138)
            at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:740)
            at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1501)
            at android.support.v4.app.FragmentManagerImpl$1.run(FragmentManager.java:458)
Added new Error
05-07 17:56:20.701 3173-3173/com.trymeagain E/art﹕ Throwing OutOfMemoryError "Failed to allocate a 74649612 byte allocation with 1048576 free bytes and 63MB until OOM"
05-07 17:56:20.703 3173-3173/com.trymeagain D/skia﹕ --- allocation failed for scaled bitmap
05-07 17:56:20.704 3173-3173/com.trymeagain D/AndroidRuntime﹕ Shutting down VM
05-07 17:56:20.704 3173-3173/com.trymeagain E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: com.trymeagain, PID: 3173
android.view.InflateException: Binary XML file line #13: Error inflating class <unknown>
at android.view.LayoutInflater.createView(LayoutInflater.java:633)
at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:55)
at android.view.LayoutInflater.onCreateView(LayoutInflater.java:682)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:741)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:806)
at android.view.LayoutInflater.inflate(LayoutInflater.java:504)
at android.view.LayoutInflater.inflate(LayoutInflater.java:414)
at android.view.LayoutInflater.inflate(LayoutInflater.java:365)
at com.trymeagain.PlusOneFragment.onCreateView(Activity2.java:13)
you getting the exception in your imageview where your image playimage2 is too large and the heap memory is not enough to allocate ...
solution-
case1 : if size need to increase on higher resolution device
if playimage2 is possible to patch-then try to reduce the size of the image..you can use tool like photoshop to do so.and then patch the image
case2 : if size need to be constant as written in xml 50dp*50dp
Just try to reduce the size of the image

Categories