architecture-components-samples: build successful ,but can't running

C:\Users\pdog18\Desktop\android-architecture-components-master\BasicSample\app\src\main\java\com\example\android\persistence\db\AppDatabase.java

Error:(31, 17) 警告: Schema export directory is not provided to the annotation processor so we cannot export the schema. You can either provide `room.schemaLocation` annotation processor argument OR set exportSchema to false.

AppDatabase

/*
 * Copyright 2017, The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.example.android.persistence.db;

import android.arch.persistence.room.Database;
import android.arch.persistence.room.RoomDatabase;
import android.arch.persistence.room.TypeConverters;

import com.example.android.persistence.db.dao.CommentDao;
import com.example.android.persistence.db.dao.ProductDao;
import com.example.android.persistence.db.entity.CommentEntity;
import com.example.android.persistence.db.entity.ProductEntity;
import com.example.android.persistence.db.converter.DateConverter;

@Database(entities = {ProductEntity.class, CommentEntity.class}, version = 1)
@TypeConverters(DateConverter.class)
public abstract class AppDatabase extends RoomDatabase {

    static final String DATABASE_NAME = "basic-sample-db";

    public abstract ProductDao productDao();

    public abstract CommentDao commentDao();
}

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 20 (2 by maintainers)

Commits related to this issue

Most upvoted comments

Try to export the schema by adding this to your app/build.gradle

android {
    ...
    defaultConfig {
        ...
        javaCompileOptions {
            annotationProcessorOptions {
                arguments = ["room.schemaLocation":
                             "$projectDir/schemas".toString()]
            }
        }
    }
}

This helped me: https://movieos.org/2017/android-room-data-binding-compile-time-errors/

I was seeing a max of 100 databinding errors, with no “real” error message. By expanding the number of messages that can be shown, check the last error and it will be a real Room compilation error! So, hopefully you can fix that error and get compilation working again 😃

allprojects {
    gradle.projectsEvaluated {
        tasks.withType(JavaCompile) {
            options.compilerArgs << "-Xmaxerrs" << "4000"
            options.compilerArgs << "-Xmaxwarns" << "4000"
        }
    }
}

For me, it also says package com.example.android.persistence.databinding does not exist; cannot find symbol class CommentItemBinding

image i have no problem after add it. I use mac os and i do not know the situation on windows. code happy.

@pdog18 国际场合还是不说中文为好

I have no problem after adding the snippet, maybe you could try File -> Invalidate Cache / Restart.

And make sure you add it at the right place, my build.gradle as follow:

image

@GurpreetSK95 were you able to solve this? I am also having the same issue with databinding after adding the room annotation processor

火钳流明。You know I am using Chinese.