Skip to content
Advertisement

Tag: android-studio

./gradlew The operation couldn’t be completed. Unable to locate a Java Runtime

When I run ./gradlew from project folder I get: The same with java: I installed JDK in Android studio, seems it’s installed in ~/Library/Android/sdk/sources/android-28 Setting export JAVA_HOME=/Users/mrgloom/Library/Android/sdk/sources/android-28/ or export JAVA_HOME=/Users/mrgloom/Library/Android/sdk produce error like: How to specify java path for gradlew ? Answer Using JDK shipped with Android Studio and setting export JAVA_HOME=/Applications/Android Studio.app/Contents/jre/Contents/Home helped me.

I cannot set a onclick listener for image button

Error: Caused by: java.lang.NullPointerException: Attempt to invoke virtual method ‘void android.widget.ImageButton.setOnClickListener(android.view.View$OnClickListener)’ on a null object reference Answer 1)You forgot about setContentView(R.layout.YOURLAYOUT) after super.onCreate 2)Make sure, that your XML file have the same ImageView ID

Show/hide Searchview using onOptionsItemSelected

I want to make my Searchview to be visible only when I open product option from the drawer, to do that I am trying using onOptionsItemSelected method to listen which options is being used. The problem is I am always get a NullPointerException everytime I tried to get my SearchView id from onOptionsItemSelected. I knew how to hide the SearchView

How to get perfect UTC Time in java/android?

I am trying to get UTC time in my application but unfortunately every time I am getting my current emulator Date and Time Instead of UTC. Tried, Calendar cal = Calendar.getInstance(TimeZone.getTimeZone(“UTC”)); ZonedDateTime utcTime = ZonedDateTime.now(ZoneOffset.UTC); DateTime now = DateTime.now(DateTimeZone.UTC); My code: Any help highly appreciated. Answer Try this code:

BottomNavigation, FragmentManager has not been attached to a host

I have moved BottomNavigation codes from MainActivity to A class I have created for the BottomNaviction to make the code more organizing. When I moved the codes I got this error java.lang.RuntimeException: Unable to start activity ComponentInfo{com.moataz.mox/com.moataz.mox.ui.view.activity.MainActivity}: java.lang.IllegalStateException: FragmentManager has not been attached to a host. Short error message FragmentManager has not been attached to a host. And The error

Advertisement