I use Sugar ORM version 1.4, on versions of Android below 5 everything works fine, but above error 5 comes out this error.

Please help.

Error: android.database.sqlite.SQLiteException: no such table: AUDIO (code 1): , while compiling: SELECT * FROM AUDIO

proguard-rules.pro

 -keep class me.lobanov.mp3downloadsfree.models.** { *; } 

My model class:

 package me.lobanov.mp3downloadsfree.models; import com.orm.SugarRecord; import lombok.Getter; import lombok.Setter; import lombok.ToString; @Getter @Setter @ToString public class Audio extends SugarRecord { private long aud_id; private String aud_artist; private String aud_title; private String aud_url; private long aud_duration; public Audio() { } public Audio(long aud_id, String aud_artist, String aud_title, String aud_url, long aud_duration){ this.aud_id = aud_id; this.aud_artist = aud_artist; this.aud_title = aud_title; this.aud_url = aud_url; this.aud_duration = aud_duration; } } 

My application class:

 public class App extends SugarApp { @Override public void onCreate() { super.onCreate(); } } 

My manifest:

 <meta-data android:name="DATABASE" android:value="mp3downloadsfree.db" /> <meta-data android:name="VERSION" android:value="5" /> <meta-data android:name="QUERY_LOG" android:value="true" /> <meta-data android:name="DOMAIN_PACKAGE_NAME" android:value="me.lobanov.mp3downloadsfree.models" /> 
  • When you roll in an application, did you remove the previous build? - Android Android
  • @AndroidAndroid, deleted several times, tested on another emulator, nothing helped, wrote that there is no such table and everything - Igor Lobanov
  • In the manifest at application registered? android: name = "com.orm.SugarApp" And attach the class code where you work with the base - Android Android
  • @AndroidAndroid, why is it necessary in the manifest if I inherit from SugarApp And I use one line List <Audio> audios = Audio.listAll (Audio.class); on android below version 5 everything works - Igor Lobanov

2 answers 2

In order for sugarORM to create the tables, you need to change the database structure in this case, your Audio class and the version in AndroidManifest.xml. The solution for you is:

  • Add a new tester field to Audio
 public class Audio extends SugarRecord { private long aud_id; private String aud_artist; private String aud_title; private String aud_url; private long aud_duration; private int tester; public Audio() { } public Audio(long aud_id, String aud_artist, String aud_title, String aud_url, long aud_duration, int tester){ this.aud_id = aud_id; this.aud_artist = aud_artist; this.aud_title = aud_title; this.aud_url = aud_url; this.aud_duration = aud_duration; this.tester= tester; } } 
  • Change the version to +1 <meta-data android:name="VERSION" android:value="6" />
  • Run the application (!) Should earn
  • Remove from audio int tester
  • Change the version to +1 <meta-data android:name="VERSION" android:value="7" />
  • Run the application

    Dug up on the Internet

      -keep public me.lobanov.mp3downloadsfree.** extends SugarApp{*;} 

    Hope will help.

    • did not help, the same error - Igor Lobanov