I have interface
#GET("/data, 2.5/forecast/daily")
Observable<MultilingualWeather> getWeatherByIdWithMultilingual(
#Query("id") String id,
#Query("lang") String lang,
#Query("appid") String appid);
MainActivity be called up in the following configuration
Retrofit retrofit_weather = new Retrofit.Builder().
baseUrl(BASE_URL).
addConverterFactory(GsonConverterFactory.create()).
addCallAdapterFactory(RxJavaCallAdapterFactory.create()).
build();
GetWeatherForLocation getWeather = retrofit_weather.create(GetWeatherForLocation.class);
Observable<MultilingualWeather> call_observable = getWeather.
getWeatherByIdWithMultilingual(
CITY_ID,
LANG,
KEY
);
subscription = call_observable.subscribe(subscriber);
The following file dependencies
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:design:23.1.1'
compile 'com.squareup.retrofit:retrofit:2.0.0-beta2'
compile 'com.squareup.retrofit:converter-gson:2.0.0-beta2'
compile 'io.reactivex:rxjava:1.0.16'
compile 'io.reactivex:rxandroid:1.0.1'
compile 'com.squareup.retrofit:adapter-rxjava:2.0.0-beta1'
}
and after all this takes off exception
FATAL EXCEPTION: main Process: com.example.alex.weatherclient, PID: 16658 java.lang.AbstractMethodError: abstract method "retrofit.CallAdapter retrofit.CallAdapter$Factory.get(java.lang.reflect.Type, java.lang.annotation.Annotation[], retrofit.Retrofit)"
Replace in build.gradle
compile 'com.squareup.retrofit:adapter-rxjava:2.0.0-beta1'
on
compile 'com.squareup.retrofit:adapter-rxjava:2.0.0-beta2'
looks like a typo. Your interface uses getWeatherByIdWithMultilingual and your code uses getWeatherByIdWithMultilingual2
Related
I just start using RxJava in my projects, i have got this error :
java.lang.NoSuchMethodError: No static method getService()Lcom/app/seddik/yomii/api/GalleryPhotosService;
In this class the error has occured, and says :
No static method getService()Lcom/app/seddik/yomii/api/GalleryPhotosService; in class Lcom/app/seddik/yomii/api/GalleryPhotosService; or its super classes (declaration of 'com.app.seddik.yomii.api.GalleryPhotosService' appears in /data/app/com.app.seddik.yomii-2/base.apk:classes27.dex)
at com.app.seddik.yomii.data.datasource.GalleryPhotosDataSource.(GalleryPhotosDataSource.java:40)
public class GalleryPhotosDataSource extends ItemKeyedDataSource<Integer, GalleryPhotosItems> {
private GalleryPhotosService galleryPhotosService;
private CompositeDisposable compositeDisposable;
private MutableLiveData<NetworkState> networkState = new MutableLiveData<>();
private MutableLiveData<NetworkState> initialLoad = new MutableLiveData<>();
/**
* Keep Completable reference for the retry event
*/
private Completable retryCompletable;
GalleryPhotosDataSource(CompositeDisposable compositeDisposable) {
this.galleryPhotosService = GalleryPhotosService.getService();
this.compositeDisposable = compositeDisposable;
}
....
The error appear in this line :
this.galleryPhotosService = GalleryPhotosService.getService();
My gradle dependencies :
apply plugin: 'com.android.application'
apply plugin: 'me.tatarka.retrolambda'
android {
compileSdkVersion 27
buildToolsVersion "27.0.0"
defaultConfig {
applicationId "com.app.seddik.yomii"
minSdkVersion 15
targetSdkVersion 27
versionCode 1
versionName "1.0"
multiDexEnabled true
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
retrolambdaConfig 'net.orfjackal.retrolambda:retrolambda:2.5.1'
// Support libraries
compile 'com.android.support:appcompat-v7:27.1.0'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.android.support:design:27.1.0'
compile 'com.android.support:support-v4:27.1.0'
// Retrofit
compile 'com.squareup.retrofit2:retrofit:2.4.0'
compile 'com.squareup.retrofit2:converter-gson:2.4.0'
compile 'com.squareup.retrofit2:adapter-rxjava2:2.4.0'
compile 'de.hdodenhof:circleimageview:2.2.0'
compile 'com.android.support:recyclerview-v7:27.1.0'
compile 'com.android.support:cardview-v7:27.1.0'
// Glide
compile 'com.github.bumptech.glide:glide:4.6.1'
compile 'com.github.bumptech.glide:compiler:4.6.1'
compile 'com.github.bumptech.glide:okhttp3-integration:4.6.1'
compile 'com.squareup.picasso:picasso:2.5.2'
// Others
compile 'com.github.chrisbanes:PhotoView:2.1.3'
compile 'com.github.varunest:sparkbutton:1.0.5'
compile 'com.makeramen:roundedimageview:2.2.1'
compile 'com.andkulikov:transitionseverywhere:1.7.8'
compile 'jp.co.cyberagent.android.gpuimage:gpuimage-library:1.3.0'
compile 'com.zhihu.android:matisse:0.4.3'
compile 'com.seatgeek:placesautocomplete:0.3-SNAPSHOT'
compile 'id.zelory:compressor:2.1.0'
compile 'org.greenrobot:eventbus:3.1.1'
compile 'com.github.florent37:shapeofview:1.1.2'
// Firebase Messaging
compile 'com.google.firebase:firebase-messaging:17.1.0'
compile 'cn.pedant.sweetalert:library:1.3'
compile 'com.android.support:multidex:1.0.1'
//Google services
compile 'com.google.android.gms:play-services-location:15.0.0'
compile 'com.google.android.gms:play-services-places:15.0.0'
// find bugs
compile 'com.google.code.findbugs:jsr305:2.0.1'
// Timber for logging
compile 'com.jakewharton.timber:timber:4.6.1'
//Architecture Components
compile "android.arch.lifecycle:extensions:1.1.0"
//Paging
compile "android.arch.paging:runtime:1.0.1"
//Rx
compile 'io.reactivex.rxjava2:rxjava:2.2.0'
compile 'io.reactivex.rxjava2:rxandroid:2.1.0'
testCompile 'junit:junit:4.12'
}apply plugin: 'com.google.gms.google-services'
This my interface Retrofit Service :
public interface GalleryPhotosService {
// Retrofit services
static GalleryPhotosService getService() {
Retrofit retrofit = new Retrofit.Builder()
.baseUrl(AppConfig.URL_UPLOAD_PHOTOS)
.addCallAdapterFactory(RxJava2CallAdapterFactory.create())
.addConverterFactory(GsonConverterFactory.create())
.build();
return retrofit.create(GalleryPhotosService.class);
}}
I have downloaded ViroCore lib the latest version (virocore-release-v_1_7_2.aar), then I added dependencies below to my build.gradle file
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:25.0.0'
implementation 'com.google.android.exoplayer:exoplayer:r2.2.0'
androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
testImplementation 'junit:junit:4.12'
implementation (name:'virocore-release-v_1_7_2', ext: 'aar')
implementation 'com.google.protobuf.nano:protobuf-javanano:3.0.0-alpha-7'
implementation 'com.amazonaws:aws-android-sdk-core:2.2.+'
implementation 'com.amazonaws:aws-android-sdk-ddb:2.2.+'
implementation 'com.amazonaws:aws-android-sdk-ddb-mapper:2.2.+'
implementation 'com.amazonaws:aws-android-sdk-cognito:2.2.+'
implementation 'com.amazonaws:aws-android-sdk-cognitoidentityprovider:2.2.+'}
and then wrote to my ViroActivity code below:
private ViroView createGVRView() {
return new ViroViewGVR(this, new ViroViewGVR.StartupListener() {
#Override
public void onSuccess() {
onRendererStart();
}
#Override
public void onFailure(ViroViewGVR.StartupError error, String errorMessage) {
onRendererFailed(error.toString(), errorMessage);
}
}, new Runnable() {
#Override
public void run() {
}
});
}
But when run the app, I always see next Exception:
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.virosample.gvr.ovr, PID: 17304
java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/vr/ndk/base/GvrLayout;
at com.viro.core.ViroViewGVR.init(ViroViewGVR.java:287)
at com.viro.core.ViroViewGVR.<init>(ViroViewGVR.java:211)
at com.example.panorama.ui.view.ViroActivityVR.createGVRView(ViroActivityVR.java:104)
at com.example.panorama.ui.view.ViroActivityVR.onCreate(ViroActivityVR.java:90)
...
Anyone knows how to resolve this exception?
I solved this issue. I added to my dependency just viro library, but I must add additionally both sdk-common.aar and core.aar which you can download at the official virocore site.
Just started to integrate Evernote SDK for Android. When I add evernote dependency
compile 'com.evernote:android-sdk:2.0.0-RC4'
project is still compilable but it crushes wjava.lang.NoClassDefFoundError appears on first try to work with Sqlite:
FATAL EXCEPTION: Process: com.myProject, PID: 14317
java.lang.NoClassDefFoundError: com.myProject.SettingsDA$$Lambda$2
at com.myProject.SettingsDA.getSettingValue(SettingsDA.java:94)
at com.myProject.MyApplication.onCreate(MyApplication.java:67)
public String getSettingValue(String key, String defaultValue) {
String query = "Select value from settings_table where id = ? ";
String result = runSingleQuery(query, new String[]{key}, null, cursor -> cursor.getString(0));
return result;
}
public <T> T runSingleQuery(final String query, final String[] params, final T value, final Func1<Cursor, T> factory) {
final SQLiteDatabase database = getWritableDatabase();
final Cursor cursor = database.rawQuery(query, params);
try {
if (cursor != null && cursor.moveToFirst()) {
return factory.call(cursor);
}
return value;
} finally {
close(cursor);
}
}
Currently dependencies are:
compile 'com.evernote:android-sdk:2.0.0-RC4'
compile 'com.jakewharton:butterknife:5.1.2'
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support:design:25.3.1'
compile 'org.apache.commons:commons-lang3:3.1'
compile 'com.squareup:otto:1.3.5'
compile 'io.reactivex:rxjava:1.0.0-rc.6'
compile 'io.reactivex:rxandroid:0.21.0'
compile 'com.google.android.gms:play-services-plus:11.0.4'
compile 'com.google.firebase:firebase-messaging:11.0.4'
compile 'com.google.firebase:firebase-invites:11.0.4'
compile 'com.google.android.gms:play-services-drive:11.0.4'
compile 'com.google.android.gms:play-services-identity:11.0.4'
compile 'com.google.android.gms:play-services-auth:11.0.4'
compile 'com.google.android.gms:play-services-places:11.0.4'
compile 'com.google.android.gms:play-services-maps:11.0.4'
compile 'com.makeramen:roundedimageview:2.2.1'
compile 'com.facebook.android:facebook-android-sdk:[4,5)'
Am I miss something to add to project?
When I add the code int activity
#Inject
lateinit var mCommonService:CommonService
The error comes
e: Error: Can't access Nullable
e: Can't find javax.annotation.Nullable
e: For details, please refer to the following stacktrace.
w: Warning: These options aren't used by any annotation processors:'[kapt.kotlin.generated]'
e: Some error(s) occurred while processing annotations. Please see the error messages above.
this is my module build.gradle
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
testCompile 'junit:junit:4.12'
compile 'com.squareup.retrofit2:retrofit:2.3.0'
compile 'com.squareup.retrofit2:converter-gson:2.3.0'
compile 'com.jakewharton.retrofit:retrofit2-rxjava2-adapter:1.0.0'
compile 'com.squareup.okhttp3:okhttp:3.8.0'
compile 'com.squareup.okhttp3:okhttp-urlconnection:3.8.0'
compile 'io.reactivex.rxjava2:rxjava:2.0.1'
compile 'io.reactivex.rxjava2:rxandroid:2.0.1'
compile 'com.google.dagger:dagger:2.11'
kapt 'com.google.dagger:dagger-compiler:2.11'
compile 'com.readystatesoftware.systembartint:systembartint:1.0.3'
compile 'com.google.code.gson:gson:2.7'
compile 'com.squareup.leakcanary:leakcanary-android:1.5.1'
// compile 'com.android.support:support-annotations:26.0.0-alpha1'
kapt "com.android.databinding:compiler:$rootProject.ext.gradle_version"
compile "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
}
This is my component
#ActivityScope
#Component(modules = arrayOf(CommonModule::class),dependencies = arrayOf(AppComponent::class))
interface CommonComponent {
fun inject(activity: MainActivity)
}
This is my module
#Module
class CommonModule {
#Singleton #Provides fun provideCommonService(retrofit: Retrofit): CommonService {
return retrofit.create(CommonService::class.java)
}
}
And this is my activity
#Inject
lateinit var mCommonService:CommonService// when i inject this,the error comes
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
getViewDataBinding(R.layout.activity_main)
DaggerCommonComponent.builder()
.appComponent(appComponent)
.commonModule(CommonModule())
.build()
.inject(this)
}
If I delete the inject code the program run correctly, I try add #JvmWildcard at CommomService #provides return type, but it still doesn't work
I am sending the image and it's description to the server using retrofit but i am unable to resolve getFile method in FileUtils.getFile method.
Here is my code:
gradle:
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:24.2.1'
testCompile 'junit:junit:4.12'
compile 'com.github.boxme:squarecamera:1.1.0'
compile 'com.intuit.sdp:sdp-android:1.0.3'
compile 'com.android.support:design:24.2.1'
compile 'org.apache.commons:commons-io:1.3.2'
compile 'com.squareup.retrofit2:retrofit:2.1.0'
compile 'com.squareup.retrofit2:converter-gson:2.1.0'
compile 'com.squareup.okhttp3:logging-interceptor:3.3.1'
compile 'com.google.android.gms:play-services:7.8.0'
compile('org.apache.httpcomponents:httpmime:4.2.4')
compile 'com.pnikosis:materialish-progress:1.7'
}
Activity :
#NonNull
private MultipartBody.Part prepareFilePart(String partName, Uri fileUri) {
// https://github.com/iPaulPro/aFileChooser/blob/master/aFileChooser/src/com/ipaulpro/afilechooser/utils/FileUtils.java
// use the FileUtils to get the actual file by uri
File file = FileUtils.getFile(this, fileUri);// here i am not able to resolve getFile method
// create RequestBody instance from file
RequestBody requestFile =
RequestBody.create(
MediaType.parse(context.getContentResolver().getType(fileUri)),
file
);
return MultipartBody.Part.createFormData(partName, file.getName(), requestFile);
}
You might have imported the wrong class
org.apache.commons.io.FileUtils
getFile(File directory, String... names)
I don't think this is a File object
Versus
com.ipaulpro.afilechooser.utils.FileUtils
getFile(Context context, String uri)