我的应用程序不在Marshmallow及以下工作,但min sdk是21.如何解决?

时间:2018-04-12 17:27:46

标签: android xml sdk

点击此处查看gradebuild app file

Min SDK屏幕截图详情:Minsdk is set to 21 & TargetSDK is set to 27

我是Android Studio的初学者,这是我的第一个应用。

点击此处查看Logcat:Logcat

这是activity_main.xml

 <?xml version="1.0" encoding="utf-8"?>
 <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="wrap_content"
    android:layout_height="match_parent"
    android:background="#ffffff"
    tools:context=".MainActivity"
    tools:layout_editor_absoluteY="25dp"
    tools:layout_width="match_parent">


<ImageButton
    android:id="@+id/cgpa"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentStart="true"
    android:layout_alignParentTop="true"
    android:layout_marginStart="16dp"
    android:layout_marginTop="16dp"
    android:background="#ffffff"
    android:onClick="clickcgpa"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent"
    app:srcCompat="@drawable/cal"
    android:contentDescription="@string/todo4" />

<ImageButton
    android:id="@+id/cal"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:layout_alignParentStart="true"
    android:background="#ffffff"
    android:onClick="clickcal"
    app:layout_constraintEnd_toStartOf="@+id/club"
    app:layout_constraintStart_toEndOf="@+id/map"
    app:layout_constraintTop_toTopOf="@+id/club"
    app:srcCompat="@drawable/calender"
    android:contentDescription="@string/todo3" />

<ImageButton
    android:id="@+id/map"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentEnd="true"
    android:layout_alignTop="@+id/cgpa"
    android:layout_marginStart="3dp"
    android:background="#ffffff"
    android:onClick="clickmap"
    app:layout_constraintEnd_toStartOf="@+id/calendar"
    app:layout_constraintHorizontal_chainStyle="packed"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="@+id/calendar"
    app:srcCompat="@drawable/marker"
    android:contentDescription="@string/todo1" />

<TextView
    android:id="@+id/textView4"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentStart="true"
    android:layout_below="@+id/cgpa"
    android:layout_marginEnd="9dp"
    android:text="@string/cgpa_calculator"
    android:textAlignment="center"
    android:textStyle="bold"
    app:layout_constraintEnd_toEndOf="@+id/cgpa"
    app:layout_constraintTop_toBottomOf="@+id/cgpa" />

<TextView
    android:id="@+id/textView5"
    android:layout_width="wrap_content"
    android:layout_height="0dp"
    android:layout_alignParentTop="true"
    android:layout_centerHorizontal="true"
    android:layout_marginStart="16dp"
    android:text="@string/campus_map"
    android:textAlignment="center"
    android:textStyle="bold"
    app:layout_constraintBottom_toBottomOf="@+id/textView6"
    app:layout_constraintStart_toStartOf="@+id/map"
    app:layout_constraintTop_toBottomOf="@+id/map" />

<TextView
    android:id="@+id/textView6"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentEnd="true"
    android:layout_alignParentTop="true"
    android:layout_marginEnd="33dp"
    android:gravity="center_vertical"
    android:text="@string/Main"
    android:textAlignment="center"
    android:textStyle="bold"
    app:layout_constraintEnd_toEndOf="@+id/calendar"
    app:layout_constraintTop_toBottomOf="@+id/calendar" />

<TextView
    android:id="@+id/textView7"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginTop="18dp"
    android:fontFamily="monospace"
    android:text="@string/coming_soon"
    android:textAppearance="@style/TextAppearance.AppCompat.Body2"
    android:textColor="#777777"
    android:textSize="24sp"
    android:textStyle="bold"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toBottomOf="@+id/textView4" />

<ImageButton
    android:id="@+id/club"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginTop="234dp"
    android:background="#ffffff"
    android:onClick="clickclub"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintStart_toEndOf="@+id/calendar"
    app:layout_constraintTop_toTopOf="parent"
    app:srcCompat="@drawable/people2"
    android:contentDescription="@string/todo2" />

<TextView
    android:id="@+id/textView8"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@string/club"
    android:textAlignment="center"
    android:textStyle="bold"
    app:layout_constraintEnd_toEndOf="@+id/club"
    app:layout_constraintStart_toStartOf="@+id/club"
    app:layout_constraintTop_toBottomOf="@+id/club" />

  </android.support.constraint.ConstraintLayout>

这是activity_welcome.xml

<?xml version="1.0" encoding="utf-8"?>
<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"
     android:background="#000000"
     tools:context=".Welcome">

<ImageView
    android:id="@+id/imageView5"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginEnd="8dp"
    android:layout_marginRight="8dp"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent"
    app:srcCompat="@drawable/logomain" />
   </android.support.constraint.ConstraintLayout>

和Manifest.xml

<?xml version="1.0" encoding="utf-8"?> 
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
   package="com.workingbros.ak.assist" android:versionCode="2">

<application
    android:icon="@drawable/logomain1"
    android:label="@string/app_name"
    android:roundIcon="@mipmap/ic_launcher_round"
    android:supportsRtl="true"
    android:theme="@style/AppTheme">
    <activity android:name=".CGPA"></activity>

    <activity android:name=".MainActivity">
    </activity>
    <activity android:name=".Welcome">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>

    </activity>
</application>

</manifest>

堆栈追踪:

04-12 23:25:46.153 30277-30277/com.workingbros.ak.assist E/Minikin: addFont failed to create font /system/fonts/NanumGothic.ttf
addFont failed to create font /system/fonts/DroidSansFallback.ttf

04-12 23:25:46.154 30277-30277/com.workingbros.ak.assist E/Minikin: addFont failed to create font /system/fonts/MTLmr3m.ttf

04-12 23:25:46.364 30277-30277/com.workingbros.ak.assist E/AndroidRuntime: FATAL EXCEPTION: main

Process: com.workingbros.ak.assist, PID: 30277

java.lang.RuntimeException: Unable to start activity ComponentInfo{com.workingbros.ak.assist/com.workingbros.ak.assist.MainActivity}: android.view.InflateException: Binary XML file line #13: Binary XML file line #13: Error inflating class ImageButton

 at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2560)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2626)
    at android.app.ActivityThread.-wrap11(ActivityThread.java)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1475)
    at android.os.Handler.dispatchMessage(Handler.java:111)
    at android.os.Looper.loop(Looper.java:207)
    at android.app.ActivityThread.main(ActivityThread.java:5740)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:905)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:766)
 Caused by: android.view.InflateException: Binary XML file line #13: Binary XML file line #13: Error inflating class ImageButton
    at android.view.LayoutInflater.inflate(LayoutInflater.java:539)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:374)
    at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:287)
    at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:139)
    at com.workingbros.ak.assist.MainActivity.onCreate(MainActivity.java:15)
    at android.app.Activity.performCreate(Activity.java:6543)
    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1113)
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2513)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2626) 
    at android.app.ActivityThread.-wrap11(ActivityThread.java) 
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1475) 
    at android.os.Handler.dispatchMessage(Handler.java:111) 
    at android.os.Looper.loop(Looper.java:207) 
    at android.app.ActivityThread.main(ActivityThread.java:5740) 
    at java.lang.reflect.Method.invoke(Native Method) 
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:905) 
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:766) 
 Caused by: android.view.InflateException: Binary XML file line #13: Error inflating class ImageButton
    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:782)
    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:835)
    at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:515)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:423) 
    at android.view.LayoutInflater.inflate(LayoutInflater.java:374) 
    at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:287) 
    at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:139) 
    at com.workingbros.ak.assist.MainActivity.onCreate(MainActivity.java:15) 
    at android.app.Activity.performCreate(Activity.java:6543) 
    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1113) 
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2513) 
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2626) 
    at android.app.ActivityThread.-wrap11(ActivityThread.java) 
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1475) 
    at android.os.Handler.dispatchMessage(Handler.java:111) 
    at android.os.Looper.loop(Looper.java:207) 
    at android.app.ActivityThread.main(ActivityThread.java:5740) 
    at java.lang.reflect.Method.invoke(Native Method) 
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:905) 
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:766) 
 Caused by: android.content.res.Resources$NotFoundException: Resource ID #0x7f070054
    at android.content.res.Resources.getValue(Resources.java:1552)
    at android.support.v7.widget.AppCompatDrawableManager.loadDrawableFromDelegates(AppCompatDrawableManager.java:328)
    at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:193)
    at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:186)
    at android.support.v7.content.res.AppCompatResources.getDrawable(AppCompatResources.java:100)
    at android.support.v7.widget.AppCompatImageHelper.loadFromAttributes(AppCompatImageHelper.java:58)
    at android.support.v7.widget.AppCompatImageButton.<init>(AppCompatImageButton.java:78)
    at android.support.v7.widget.AppCompatImageButton.<init>(AppCompatImageButton.java:68)
    at android.support.v7.app.AppCompatViewInflater.createImageButton(AppCompatViewInflater.java:201)
    at android.support.v7.app.AppCompatViewInflater.createView(AppCompatViewInflater.java:121)
    at android.support.v7.app.AppCompatDelegateImplV9.createView(AppCompatDelegateImplV9.java:1035)
    at android.support.v7.app.AppCompatDelegateImplV9.onCreateView(AppCompatDelegateImplV9.java:1092)
    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:746)
    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704) 
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:835) 
    at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798) 
    at android.view.LayoutInflater.inflate(LayoutInflater.java:515) 
    at android.view.LayoutInflater.inflate(LayoutInflater.java:423) 
    at android.view.LayoutInflater.inflate(LayoutInflater.java:374) 
    at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:287) 
    at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:139) 
    at com.workingbros.ak.assist.MainActivity.onCreate(MainActivity.java:15) 
    at android.app.Activity.performCreate(Activity.java:6543) 
    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1113) 
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2513) 
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2626) 
    at android.app.ActivityThread.-wrap11(ActivityThread.java) 
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1475) 
    at android.os.Handler.dispatchMessage(Handler.java:111) 
    at android.os.Looper.loop(Looper.java:207) 
    at android.app.ActivityThread.main(ActivityThread.java:5740) 
    at java.lang.reflect.Method.invoke(Native Method) 
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:905) 
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:766) 

MainActivity.java

package com.workingbros.ak.assist;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity; 
import android.os.Bundle;
import android.view.View;
import android.widget.ImageButton;
import android.widget.Toast;

public class MainActivity extends AppCompatActivity {
ImageButton cgpa,cal,map,club;
     @Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    cgpa= findViewById(R.id.cgpa);
    map=findViewById(R.id.map);
    club=findViewById(R.id.club);
    cal=findViewById(R.id.cal);


}
public void clickcgpa(View v){
    Intent main=new Intent(MainActivity.this,CGPA.class);
    startActivity(main);
}
public void clickmap(View v)
{
    Toast.makeText(this,"Coming Soon",Toast.LENGTH_SHORT).show();
}
public void clickclub(View v)
{
    Toast.makeText(this,"Coming Soon",Toast.LENGTH_SHORT).show();
}
public void clickcal(View v)
    { 
        Toast.makeText(this,"Coming Soon",Toast.LENGTH_SHORT).show();
    }
}

Welcome.java

package com.workingbros.ak.assist;

import android.content.Intent;
import android.os.Handler;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.Window;
import android.view.WindowManager;


public class Welcome extends AppCompatActivity {
private static int SPLASH_TIME_OUT=1000;
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);

    setContentView(R.layout.activity_welcome);

    new Handler().postDelayed(new Runnable(){
        @Override
        public void run(){
            Intent homeIntent=new Intent(Welcome.this,MainActivity.class);
            startActivity(homeIntent);
        finish();
        }
    },SPLASH_TIME_OUT);
}
}

请告诉我错误在哪里?

应用修复后的编译错误:

org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app:compileDebugJavaWithJavac'.

at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:100)

at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:70)

at org.gradle.api.internal.tasks.execution.OutputDirectoryCreatingTaskExecuter.execute(OutputDirectoryCreatingTaskExecuter.java:51)
at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:62)
at org.gradle.api.internal.tasks.execution.ResolveTaskOutputCachingStateExecuter.execute(ResolveTaskOutputCachingStateExecuter.java:54)
at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:60)
at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:97)
at org.gradle.api.internal.tasks.execution.CleanupStaleOutputsExecuter.execute(CleanupStaleOutputsExecuter.java:87)
at org.gradle.api.internal.tasks.execution.ResolveTaskArtifactStateTaskExecuter.execute(ResolveTaskArtifactStateTaskExecuter.java:52)
at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:52)
at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:54)
at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)
at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:34)
at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker$1.run(DefaultTaskGraphExecuter.java:248)
at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)
at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:199)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:110)
at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:241)
at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:230)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.processTask(DefaultTaskPlanExecutor.java:123)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.access$200(DefaultTaskPlanExecutor.java:79)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:104)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:98)
at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.execute(DefaultTaskExecutionPlan.java:626)
at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.executeWithTask(DefaultTaskExecutionPlan.java:581)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.run(DefaultTaskPlanExecutor.java:98)
at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63)
at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:46)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)
at java.lang.Thread.run(Thread.java:745)

Caused by: org.gradle.api.internal.tasks.compile.CompilationFailedException: Compilation failed; see the compiler error output for details.

at org.gradle.api.internal.tasks.compile.JdkJavaCompiler.execute(JdkJavaCompiler.java:50)

at org.gradle.api.internal.tasks.compile.JdkJavaCompiler.execute(JdkJavaCompiler.java:35)
at org.gradle.api.internal.tasks.compile.NormalizingJavaCompiler.delegateAndHandleErrors(NormalizingJavaCompiler.java:98)
at org.gradle.api.internal.tasks.compile.NormalizingJavaCompiler.execute(NormalizingJavaCompiler.java:51)
at org.gradle.api.internal.tasks.compile.NormalizingJavaCompiler.execute(NormalizingJavaCompiler.java:37)
at org.gradle.api.internal.tasks.compile.CleaningJavaCompilerSupport.execute(CleaningJavaCompilerSupport.java:35)
at org.gradle.api.internal.tasks.compile.CleaningJavaCompilerSupport.execute(CleaningJavaCompilerSupport.java:25)
at org.gradle.api.internal.tasks.compile.incremental.IncrementalCompilationFinalizer.execute(IncrementalCompilationFinalizer.java:39)
at org.gradle.api.internal.tasks.compile.incremental.IncrementalCompilationFinalizer.execute(IncrementalCompilationFinalizer.java:24)
at org.gradle.api.tasks.compile.JavaCompile.performCompilation(JavaCompile.java:207)
at org.gradle.api.tasks.compile.JavaCompile.compile(JavaCompile.java:133)
at com.android.build.gradle.tasks.factory.AndroidJavaCompile.compile(AndroidJavaCompile.java:125)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:73)
at org.gradle.api.internal.project.taskfactory.IncrementalTaskAction.doExecute(IncrementalTaskAction.java:46)
at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:39)
at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:26)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$1.run(ExecuteActionsTaskExecuter.java:121)
at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)
at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:199)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:110)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:110)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:92)
... 32 more

1 个答案:

答案 0 :(得分:0)

您已根据日历 ID对地图图像按钮, textView6 TextView和分会 ImageButton进行了限制,但是正如我在您的activity_main.xml文件中看到的那样,没有具有日历 ID的视图。可能是你早些时候有,但之后你已经将它改为 cal id。因此,您必须根据 cal 而不是日历 ID来引用您的视图约束。由于ID错误,您会出现充气错误。

我已经修改了您的activity_main.xml,如下所示。您只需将其复制并粘贴到代码中即可。

已编辑的activity_main.xml

    <?xml version="1.0" encoding="utf-8"?>
<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="wrap_content"
    android:layout_height="match_parent"
    android:background="#ffffff"
    tools:context=".MainActivity"
    tools:layout_editor_absoluteY="25dp"
    tools:layout_width="match_parent">


    <ImageButton
        android:id="@+id/cgpa"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentStart="true"
        android:layout_alignParentTop="true"
        android:layout_marginStart="16dp"
        android:layout_marginTop="16dp"
        android:background="#ffffff"
        android:onClick="clickcgpa"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:srcCompat="@drawable/cal"
        android:contentDescription="@string/todo4" />

    <ImageButton
        android:id="@+id/cal"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_alignParentStart="true"
        android:background="#ffffff"
        android:onClick="clickcal"
        app:layout_constraintEnd_toStartOf="@+id/club"
        app:layout_constraintStart_toEndOf="@+id/map"
        app:layout_constraintTop_toTopOf="@+id/club"
        app:srcCompat="@drawable/calender"
        android:contentDescription="@string/todo3" />

    <ImageButton
        android:id="@+id/map"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentEnd="true"
        android:layout_alignTop="@+id/cgpa"
        android:layout_marginStart="3dp"
        android:background="#ffffff"
        android:onClick="clickmap"
        app:layout_constraintEnd_toStartOf="@+id/cal"
        app:layout_constraintHorizontal_chainStyle="packed"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="@+id/cal"
        app:srcCompat="@drawable/marker"
        android:contentDescription="@string/todo1" />

    <TextView
        android:id="@+id/textView4"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentStart="true"
        android:layout_below="@+id/cgpa"
        android:layout_marginEnd="9dp"
        android:text="@string/cgpa_calculator"
        android:textAlignment="center"
        android:textStyle="bold"
        app:layout_constraintEnd_toEndOf="@+id/cgpa"
        app:layout_constraintTop_toBottomOf="@+id/cgpa" />

    <TextView
        android:id="@+id/textView5"
        android:layout_width="wrap_content"
        android:layout_height="0dp"
        android:layout_alignParentTop="true"
        android:layout_centerHorizontal="true"
        android:layout_marginStart="16dp"
        android:text="@string/campus_map"
        android:textAlignment="center"
        android:textStyle="bold"
        app:layout_constraintBottom_toBottomOf="@+id/textView6"
        app:layout_constraintStart_toStartOf="@+id/map"
        app:layout_constraintTop_toBottomOf="@+id/map" />

    <TextView
        android:id="@+id/textView6"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentEnd="true"
        android:layout_alignParentTop="true"
        android:layout_marginEnd="33dp"
        android:gravity="center_vertical"
        android:text="@string/Main"
        android:textAlignment="center"
        android:textStyle="bold"
        app:layout_constraintEnd_toEndOf="@+id/cal"
        app:layout_constraintTop_toBottomOf="@+id/cal" />

    <TextView
        android:id="@+id/textView7"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="18dp"
        android:fontFamily="monospace"
        android:text="@string/coming_soon"
        android:textAppearance="@style/TextAppearance.AppCompat.Body2"
        android:textColor="#777777"
        android:textSize="24sp"
        android:textStyle="bold"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/textView4" />

    <ImageButton
        android:id="@+id/club"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="234dp"
        android:background="#ffffff"
        android:onClick="clickclub"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toEndOf="@+id/cal"
        app:layout_constraintTop_toTopOf="parent"
        app:srcCompat="@drawable/people2"
        android:contentDescription="@string/todo2" />

    <TextView
        android:id="@+id/textView8"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/club"
        android:textAlignment="center"
        android:textStyle="bold"
        app:layout_constraintEnd_toEndOf="@+id/club"
        app:layout_constraintStart_toStartOf="@+id/club"
        app:layout_constraintTop_toBottomOf="@+id/club" />

</android.support.constraint.ConstraintLayout>

以后如果您想更改任何视图ID,我建议您从设计部分更改它,因为它会要求您选择在您使用它的所有地方更改ID。因此,您无需在每个地方手动更新它。

更新

正如我在您的项目代码中看到的(在私人聊天中收到),只有drawable-v24中有一些图像。因此,这些图片仅适用于here所述的某些版本。因此,您必须将您的图像放在drawable文件夹中,以便在所有版本中兼容您的应用程序。

正如我所看到的,只有cal.png而不是people2.png文件夹中有两个图片drawable-v24drawable。所以,简单地将它们复制并粘贴到drawable文件夹中,一切都会好的。您可以在minsdk和targetsdk版本之间具有版本的每台设备上运行项目。