我已经在我的手机中成功启动(构建输出)一个简单的用户界面,使用 Android Studio 布局编辑器创建一个包含文本框和发送按钮的布局。现在我想通过单击此按钮显示用户编写的消息。为此,我让应用程序在点击按钮时将文本框的内容发送到另一个活动。我在“MainActivity”文件中添加了一些代码,当用户点击发送按钮时,该文件启动一个新活动以显示一条消息 以下是失败的构建输出的详细信息,其中初始项目构建成功,安装也可以观察如下:****(注意问题红线已通过将它们放在双星中突出显示):
02/12 23:27:45: Launching 'DisplayMessageActivity' on Xiaomi M2006C3LI.
Install successfully finished in 7 s 675 ms.
$ adb shell am start -n "com.example.mylearningapp/com.example.mylearningapp.DisplayMessageActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER
Connected to process 28173 on device 'xiaomi-m2006c3li-CI9DUGEYGA9PR4PZ'.
Capturing and displaying logcat messages from application. This behavior can be disabled in the "Logcat output" section of the "Debugger" settings page.
I/FeatureParser: can't find dandelion.xml in assets/device_features/,it may be in /vendor/etc/device_features
**E/libc: Access denied finding property "ro.vendor.df.effect.conflict"**
W/e.mylearningapp: type=1400 audit(0.0:6751): avc: denied { read } for name="u:object_r:vendor_default_prop:s0" dev="tmpfs" ino=1416 scontext=u:r:untrusted_app:s0:c220,c256,c512,c768 tcontext=u:object_r:vendor_default_prop:s0 tclass=file permissive=0
D/libMEOW: applied 0 plugin for [com.example.mylearningapp].
D/ForceDarkHelper: updateByCheckExcludeList: pkg: com.example.mylearningapp activity: com.example.mylearningapp.DisplayMessageActivity@42d0c14
D/ForceDarkHelper: updateByCheckExcludeList: pkg: com.example.mylearningapp activity: com.example.mylearningapp.DisplayMessageActivity@42d0c14
W/e.mylearningap: Accessing hidden method Landroid/view/View;->computeFitSystemWindows(Landroid/graphics/Rect;Landroid/graphics/Rect;)Z (greylist, reflection, allowed)
W/e.mylearningap: Accessing hidden method Landroid/view/ViewGroup;->makeOptionalFitsSystemWindows()V (greylist, reflection, allowed)
D/ForceDarkHelper: updateByCheckExcludeList: pkg: com.example.mylearningapp activity: com.example.mylearningapp.DisplayMessageActivity@42d0c14
D/ForceDarkHelper: updateByCheckExcludeList: pkg: com.example.mylearningapp activity: com.example.mylearningapp.DisplayMessageActivity@42d0c14
I/SurfaceFactory: [static] sSurfaceFactory = com.mediatek.view.impl.SurfaceFactoryImpl@51d13e0
I/PowerHalWrapper: PowerHalWrapper.getInstance
D/ViewRootImpl[DisplayMessageActivity]: hardware acceleration = true , fakeHwAccelerated = false, sRendererDisabled = false, forceHwAccelerated = false, sSystemRendererDisabled = false
D/libMEOW: applied 0 plugin for [com.example.mylearningapp].
I/InputTransport: Create ARC handle: 0xd68845b0
V/PhoneWindow: DecorView setVisiblity: visibility = 0, Parent = android.view.ViewRootImpl@16f8e0c, this = DecorView@30f5355[DisplayMessageActivity]
W/Looper: Slow Looper main: Activity com.example.mylearningapp/.DisplayMessageActivity is 968ms late (wall=617ms running=513ms ClientTransaction{ callbacks=[android.app.servertransaction.LaunchActivityItem] lifecycleRequest=android.app.servertransaction.ResumeActivityItem }) because of 1 msg, msg 1 took 971ms (seq=2 running=823ms runnable=81ms io=16ms late=2ms h=android.app.ActivityThread$H w=110)
W/Looper: Slow Looper main: Activity com.example.mylearningapp/.DisplayMessageActivity is 1582ms late (wall=1ms running=0ms ClientTransaction{ callbacks=[android.app.servertransaction.TopResumedActivityChangeItem] }) because of 2 msg, msg 1 took 971ms (seq=2 running=823ms runnable=81ms io=16ms late=2ms h=android.app.ActivityThread$H w=110), msg 2 took 617ms (seq=3 running=513ms runnable=2ms io=54ms late=968ms h=android.app.ActivityThread$H w=159)
D/libMEOW: applied 0 plugin for [com.example.mylearningapp].
I/GPUD: @gpudInitialize: successfully initialized with GL, dbg=0 mmdump_dbg=0 mmpath_dbg=0
D/Surface: Surface::connect(this=0xd1d58000,api=1)
D/Surface: Surface::setBufferCount(this=0xd1d58000,bufferCount=3)
Surface::allocateBuffers(this=0xd1d58000)
W/Gralloc3: mapper 3.x is not supported
**E/ion: ioctl c0044901 failed with code -1: Invalid argument**
I/e.mylearningap: ProcessProfilingInfo new_methods=1211 is saved saved_to_disk=1 resolve_classes_delay=8000
***Androidmanifest.xml***
<?xml version="1.0" encoding="utf-8"?>
<!--suppress ALL -->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.example.mylearningapp">
<application
android:allowBackup="true"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.MyLearningApp"
>
<activity android:name=".DisplayMessageActivity"
android:parentActivityName=".MainActivity"
android:exported="true"
tools:ignore="ExtraText">
<!-- The meta-data tag is required if you support API level 15 and lower -->
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".MainActivity" />
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
**I have also tried it by entering this code in build.gradle:**
android {
....
....
sourceSets {
main.java.srcDirs += 'src/main/AndroidManifest.xml'
}
}