android – 由以下引起:java.lang.IllegalArgumentException:无法猜测com.example.example.databinding.ContentClassApplicationMyClass1Binding

前端之家收集整理的这篇文章主要介绍了android – 由以下引起:java.lang.IllegalArgumentException:无法猜测com.example.example.databinding.ContentClassApplicationMyClass1Binding前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我将 Android工作室从3.0更新到3.1并将Gradle从3.1更新到4.4后,我在android中遇到此错误.

我该如何解决

它与Gradle 3.1和android studio 3.0一起正常工作.

我怎样才能让它发挥作用?

Gradle app:

  1. buildscript {
  2. repositories {
  3. maven { url 'https://maven.fabric.io/public' }
  4. }
  5.  
  6. dependencies {
  7. classpath 'io.fabric.tools:gradle:1.+'
  8.  
  9. }
  10. }
  11. apply plugin: 'com.android.application'
  12. apply plugin: 'io.fabric'
  13.  
  14. repositories {
  15.  
  16. mavenCentral()
  17. google()
  18. maven { url 'https://maven.fabric.io/public' }
  19. }
  20.  
  21.  
  22. android {
  23. compileSdkVersion 27
  24.  
  25. dataBinding {
  26. enabled = true
  27. }
  28.  
  29. defaultConfig {
  30. applicationId "com.example.example"
  31. minSdkVersion 22
  32. targetSdkVersion 23
  33. versionCode 13
  34. versionName "1.13"
  35. testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
  36. vectorDrawables.useSupportLibrary = true
  37.  
  38. multiDexEnabled true
  39. }
  40.  
  41. buildTypes {
  42. release {
  43. minifyEnabled false
  44. proguardFiles getDefaultProguardFile('proguard-android.txt'),'proguard-rules.pro'
  45. }
  46. }
  47.  
  48.  
  49.  
  50.  
  51. packagingOptions {
  52. exclude 'Meta-INF/DEPENDENCIES'
  53. exclude 'Meta-INF/LICENSE'
  54. exclude 'Meta-INF/LICENSE.txt'
  55. exclude 'Meta-INF/license.txt'
  56. exclude 'Meta-INF/NOTICE'
  57. exclude 'Meta-INF/NOTICE.txt'
  58. exclude 'Meta-INF/notice.txt'
  59. exclude 'Meta-INF/ASL2.0'
  60. }
  61.  
  62.  
  63. }
  64.  
  65. dependencies {
  66. implementation fileTree(include: ['*.jar'],dir: 'libs')
  67. implementation 'com.android.support:appcompat-v7:27.0.2'
  68.  
  69. implementation 'com.android.support.constraint:constraint-layout:1.0.2'
  70. implementation 'com.android.support:design:27.0.2'
  71. implementation 'com.google.firebase:firebase-messaging:11.8.0'
  72. implementation 'com.google.firebase:firebase-crash:11.8.0'
  73. implementation 'com.google.firebase:firebase-core:11.8.0'
  74. testImplementation 'junit:junit:4.12'
  75. androidTestImplementation 'com.android.support.test:runner:1.0.1'
  76. androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
  77. compile 'com.amazonaws:aws-android-sdk-cognitoidentityprovider:2.6.8'
  78. compile 'com.squareup.retrofit2:retrofit:2.2.0'
  79. compile 'com.squareup.retrofit2:converter-gson:2.2.0'
  80. compile 'com.amazonaws:aws-android-sdk-core:2.6.8'
  81. compile 'com.amazonaws:aws-android-sdk-s3:2.6.8'
  82. compile 'com.amazonaws:aws-android-sdk-ddb:2.6.8'
  83. compile 'com.github.twinkle942910:monthyearpicker:0.0.1'
  84. compile('com.crashlytics.sdk.android:crashlytics:2.9.0@aar') {
  85. transitive = true;
  86. }
  87. compile 'com.google.android.gms:play-services-location:11.8.0'
  88. compile 'com.zsoltsafrany:needle:1.0.0'
  89. implementation 'com.android.support:cardview-v7:27.0.2'
  90. compile 'com.white:progressview:1.0.1'
  91. compile 'br.com.simplepass:loading-button-android:1.8.1'
  92. implementation files('/libs/android-sdk-0.1.0.jar')
  93. compile 'com.android.support:support-v4:27.0.2'
  94.  
  95. compile 'com.clevertap.android:clevertap-android-sdk:3.1.8'
  96.  
  97.  
  98. compile 'testfairy:testfairy-android-sdk:1.+@aar'
  99.  
  100.  
  101. implementation 'com.github.bumptech.glide:glide:4.6.1'
  102. annotationProcessor 'com.github.bumptech.glide:compiler:4.6.1'
  103. }
  104.  
  105.  
  106.  
  107.  
  108. apply plugin: 'com.google.gms.google-services'

摇篮项目:

  1. // Top-level build file where you can add configuration options common to all sub-projects/modules.
  2.  
  3. buildscript {
  4.  
  5. repositories {
  6. google()
  7. jcenter()
  8. }
  9. dependencies {
  10. classpath 'com.android.tools.build:gradle:3.1.0'
  11. classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.2.31"
  12.  
  13. // NOTE: Do not place your application dependencies here; they belong
  14. // in the individual module build.gradle files
  15. classpath 'com.google.gms:google-services:3.1.0'
  16. }
  17. }
  18.  
  19. allprojects {
  20. repositories {
  21. google()
  22. jcenter()
  23. }
  24. }
  25.  
  26. task clean(type: Delete) {
  27. delete rootProject.buildDir
  28. }

Gradle-wrapper.Properties:

  1. distributionBase=GRADLE_USER_HOME
  2. distributionPath=wrapper/dists
  3. zipStoreBase=GRADLE_USER_HOME
  4. zipStorePath=wrapper/dists
  5. distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip

Gradle.properties

  1. org.gradle.jvmargs=-Xmx1536m
  2. android.databinding.enableV2=true

Layout.xml

  1. <?xml version="1.0" encoding="utf-8"?>
  2. <layout xmlns:android="http://schemas.android.com/apk/res/android"
  3. xmlns:app="http://schemas.android.com/apk/res-auto"
  4. xmlns:tools="http://schemas.android.com/tools">
  5.  
  6. <android.support.constraint.ConstraintLayout
  7. android:layout_width="match_parent"
  8. android:layout_height="match_parent"
  9. android:background="@color/white"
  10. android:padding="4dp"
  11. app:layout_behavior="@string/appbar_scrolling_view_behavior"
  12. tools:context=".Class_application_MyClass1"
  13. tools:showIn="@layout/activity_class_application_myclass_1">
  14.  
  15.  
  16. <ScrollView
  17. android:id="@+id/scrollView2"
  18. android:layout_width="match_parent"
  19. android:layout_height="match_parent"
  20. android:layout_marginBottom="60dip"
  21. android:layout_marginTop="20dip"
  22. android:padding="10dp"
  23. app:layout_constraintEnd_toEndOf="parent"
  24. app:layout_constraintLeft_toLeftOf="parent"
  25. app:layout_constraintRight_toRightOf="parent"
  26. app:layout_constraintStart_toStartOf="parent"
  27. app:layout_constraintTop_toTopOf="parent">
  28.  
  29.  
  30. <android.support.v7.widget.CardView
  31. android:layout_width="match_parent"
  32. android:layout_height="wrap_content"
  33. app:cardUseCompatPadding="true">
  34.  
  35. <LinearLayout
  36.  
  37. android:layout_width="match_parent"
  38. android:layout_height="wrap_content"
  39. android:focusableInTouchMode="true"
  40. android:orientation="vertical"
  41. android:padding="25dp">
  42.  
  43.  
  44. <android.support.design.widget.TextInputLayout
  45.  
  46. android:id="@+id/name_TextInputLayout"
  47. android:layout_width="match_parent"
  48. android:layout_height="wrap_content"
  49. android:layout_marginBottom="25dp">
  50.  
  51. <android.support.design.widget.TextInputEditText
  52. android:id="@+id/name"
  53. android:layout_width="match_parent"
  54.  
  55. android:layout_height="wrap_content"
  56. android:drawablePadding="10dp"
  57. android:hint="Name"
  58. android:imeOptions="actionNext"
  59. android:singleLine="true"
  60. android:text=""
  61. android:textSize="13sp" />
  62.  
  63. </android.support.design.widget.TextInputLayout>
  64.  
  65. <android.support.design.widget.TextInputLayout
  66.  
  67. android:id="@+id/number_TextInputLayout"
  68. android:layout_width="match_parent"
  69. android:layout_height="match_parent"
  70. android:layout_marginBottom="25dp">
  71.  
  72. <android.support.design.widget.TextInputEditText
  73. android:id="@+id/number"
  74. android:layout_width="match_parent"
  75. android:layout_height="wrap_content"
  76. android:drawablePadding="10dp"
  77. android:hint="number"
  78. android:inputType="textCapCharacters"
  79. android:maxLength="10"
  80. android:text=""
  81. android:textAllCaps="true"
  82. android:textSize="13sp" />
  83.  
  84. </android.support.design.widget.TextInputLayout>
  85.  
  86. <android.support.design.widget.TextInputLayout
  87.  
  88. android:id="@+id/classnumber_TextInputLayout"
  89. android:layout_width="match_parent"
  90. android:layout_height="wrap_content"
  91. android:layout_marginBottom="25dp">
  92.  
  93. <android.support.design.widget.TextInputEditText
  94. android:id="@+id/class_number"
  95. android:layout_width="match_parent"
  96. android:layout_height="wrap_content"
  97. android:drawablePadding="10dp"
  98. android:hint="class"
  99. android:imeOptions="actionNext"
  100. android:inputType="textCapCharacters"
  101. android:maxLength="15"
  102. android:singleLine="true"
  103. android:text=""
  104. android:textSize="12sp" />
  105. </android.support.design.widget.TextInputLayout>
  106.  
  107.  
  108. </LinearLayout>
  109.  
  110. </android.support.v7.widget.CardView>
  111.  
  112. </ScrollView>
  113.  
  114.  
  115. </android.support.constraint.ConstraintLayout>
  116. </layout>

Activity.xml

  1. <?xml version="1.0" encoding="utf-8"?>
  2.  
  3. <layout xmlns:android="http://schemas.android.com/apk/res/android"
  4. xmlns:app="http://schemas.android.com/apk/res-auto"
  5. xmlns:tools="http://schemas.android.com/tools">
  6.  
  7. <android.support.design.widget.CoordinatorLayout
  8. android:id="@+id/top_layout"
  9. android:layout_width="match_parent"
  10. android:layout_height="match_parent"
  11. tools:context=".Class_application_MyClass1">
  12.  
  13. <android.support.design.widget.AppBarLayout
  14. android:layout_width="match_parent"
  15. android:layout_height="wrap_content"
  16. android:theme="@style/AppTheme.AppBarOverlay">
  17.  
  18. <android.support.v7.widget.Toolbar
  19. android:id="@+id/toolbar"
  20. android:layout_width="match_parent"
  21. android:layout_height="?attr/actionBarSize"
  22. android:background="@color/fundscorner_blue"
  23. app:popupTheme="@style/AppTheme.PopupOverlay" />
  24.  
  25. <android.support.constraint.ConstraintLayout
  26. android:id="@+id/linearLayout3"
  27. android:layout_width="fill_parent"
  28. android:layout_height="20dp"
  29. android:background="@color/white"
  30. app:layout_anchor="@+id/content_class_application_myclass_1"
  31. app:layout_anchorGravity="top|center">
  32.  
  33. <com.white.progressview.HorizontalProgressView
  34. android:id="@+id/progress100"
  35. android:layout_width="match_parent"
  36. android:layout_height="wrap_content"
  37. android:padding="10dp"
  38. android:progress="25"
  39. app:progressReachColor="@color/colorPrimary"
  40. app:progressTextColor="@color/colorPrimary"
  41. app:progressTextVisible="false"
  42. android:minHeight="20dip"
  43. android:maxHeight="20dip"
  44.  
  45. />
  46. </android.support.constraint.ConstraintLayout>
  47.  
  48. </android.support.design.widget.AppBarLayout>
  49.  
  50.  
  51. <include
  52. android:id="@+id/content_class_application_myclass_1"
  53. layout="@layout/content_class_application_myclass_1"/>
  54.  
  55. <LinearLayout
  56. app:layout_anchor="@+id/content_class_application_myclass_1"
  57. app:layout_anchorGravity="bottom|center"
  58. android:layout_width="match_parent"
  59. android:layout_height="wrap_content">
  60.  
  61. <Button
  62. android:background="@drawable/ripple"
  63. style="?borderlessButtonStyle"
  64. android:id="@+id/button_stage1"
  65. android:layout_width="match_parent"
  66. android:layout_height="wrap_content"
  67. android:backgroundTint="@color/fundscorner_blue"
  68. android:text="Next"
  69. android:textColor="@color/white"
  70. />
  71.  
  72. </LinearLayout>
  73.  
  74.  
  75. </android.support.design.widget.CoordinatorLayout>
  76. </layout>

在JAVA文件中:

  1. ActivityClassApplicationMyClass1Binding binding;
  2.  
  3. binding = DataBindingUtil.setContentView(this,R.layout.activity_class_application_myclass_1);
  4.  
  5.  
  6.  
  7. binding.name.settext("Name");

解决方法

它是因为您使用数据绑定的类名或包名.这些类(使用数据绑定)必须以大写单词开头,包以小写开头.

猜你在找的Android相关文章