Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
111 views
in Technique[技术] by (71.8m points)

java - Unrelated app name showing on execution of Android apps - gradle error?

I am new to Android Studio and I don't know all the ins and out of the build process yet. All my projects were working fine until recently, when it seems that something happened (maybe I touched something unwittingly?) and now even new, fresh projects with a mere onCreate() don′t work. Not even the fresh ones with the helloworld tag, so it's not to do with the code. I was checking the logcat and they all show the following on execution:

2020-12-16 10:26:39.543 28376-28376/? E/AndroidRuntime: FATAL EXCEPTION: main
    Process: grass.mary.newApp, PID: 28376
    java.lang.RuntimeException: Unable to start activity ComponentInfo{grass.mary.newApp/grass.mary.newApp.MainActivity}: android.view.InflateException: Binary XML file line #26: ScrollView can host only one direct child
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2817)

followed by:

   --------- beginning of system
2021-01-09 12:21:49.819 22348-13682/? E/memtrack: Couldn't load memtrack module
2021-01-09 12:22:34.847 1656-1662/? E/zygote: Timed out waiting for threads to suspend, waited for 10.000s

And perhaps more tellingly, on the Run tab it says in red:

Installation did not succeed.
The application could not be installed.

List of apks:
[0] 'C:UsersuserAndroidStudioProjectsestappuildoutputsapkdebugapp-debug.apk'
Installation failed due to: 'Failed to create install session with 'cmd package install-create -r -t -S 1749180''
Retry

I find strange that it says Process: grass.mary.newApp, PID: 28376 because 'newApp' is not the app that I'm currently running. And this happens with all other projects that used to work fine, they all display the exact same error on execution with the line Process: grass.mary.newApp, PID: 28376 which references an App that is totally unrelated to the one I'm executing (I did create this 'newApp' in the past and it's in the projects folder).

Any ideas of what the issue might be?

question from:https://stackoverflow.com/questions/65643441/unrelated-app-name-showing-on-execution-of-android-apps-gradle-error

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

The line

Caused by: java.lang.IllegalStateException: ScrollView can host only one direct child

in the stack trace gives a hint that in the application of package grass.mary.newApp you are using a ScrollView with more than one child.

Remember that according to the docs of ScrollView:

... Scroll view may have only one direct child placed within it. ...

To sovle this, you may put all your children into a LinearLayout with vertical orientation and then put the LinearLayout into the ScrollView.

Also note that you should take care of your application's package name inside the manifest file. According to the App Manifest Overview:

... once the APK is compiled, the package attribute also represents your app's universally unique application ID.

And, as far as I know, the package name in the manifest should be the same with the Gradle's gradle.build module file (in the constant named applicationId). You may read the corresponding page on changing the id for more information.

Another thing to note is that, in Android, you are not only using the Java/Kotlin coded files, but also numerous XML files such as those under the res directory of your project. In your case, if you are just setting the content view with setContentView in your main entry point's Activity and you are using a layout from the R class to set it, then the problem with the ScrollView may rely on the fact that the corresponding layout (such as for example res/layout/activity_main.xml) uses a ScrollView with multiple elements (instead of only one) and that's probably why you are seeing this exception.


Edit 1:

Now you have updated your question, seems like the problem may be relevant to this other question. Can you check it out and tell us if the given answers on that post solved the problem?

Basically what they suggest is that maybe you did not allocate enough RAM and/or space for your emulated device (ie the device has already many applications in it and cannot install more, unless you wipe the data or increase the space or uninstall some stuff first).

If that doesn't work, the other suggested solution on that post is that you should edit the installation configurations. Be aware here that they are talking about Android Studio version 3.5.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...