java - 错误:找不到合适的方法添加(字符串,类)
问题描述
感谢; 我是 Android Studio 和 java 的新手,但我尽可能地尝试了我也可以做谷歌,但我做不到,请任何人都可以帮助我解决这个错误。请帮我!我在 Android Studio 中构建 java 代码时收到此错误:找不到适合 add(String,Class) 的方法。
package com.uit.huydaoduc.hieu.chi.hhapp.Main.Driver.v2;
import android.net.Uri;
import androidx.viewpager.widget.ViewPager;
//import android.support.v7.app.AppCompatActivity;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import com.uit.huydaoduc.hieu.chi.hhapp.Main.Driver.v2.RouteRequestManagerFragment;
import com.uit.huydaoduc.hieu.chi.hhapp.R;
import com.ogaclejapan.smarttablayout.SmartTabLayout;
import com.ogaclejapan.smarttablayout.utils.v4.FragmentPagerItemAdapter;
import com.ogaclejapan.smarttablayout.utils.v4.FragmentPagerItems;
//import android.support.v13.app.FragmentPagerAdapter;
import cn.bingoogolapple.titlebar.BGATitleBar;
public class DriverActivity extends AppCompatActivity
implements RouteRequestManagerFragment.OnRouteRequestManagerFragmentListener{
BGATitleBar titleBar;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_driver);
FragmentPagerItemAdapter adapter = new FragmentPagerItemAdapter(
getSupportFragmentManager(), FragmentPagerItems.with(this)
.add("Your routes", RouteRequestManagerFragment.class)
.create());
ViewPager viewPager = (ViewPager) findViewById(R.id.viewpager);
viewPager.setAdapter(adapter);
SmartTabLayout viewPagerTab = (SmartTabLayout) findViewById(R.id.viewpagertab);
viewPagerTab.setViewPager(viewPager);
Init();
Event();
}
private void Init() {
titleBar = (BGATitleBar) findViewById(R.id.titlebar);
}
private void Event() {
titleBar.setDelegate(new BGATitleBar.Delegate() {
@Override
public void onClickLeftCtv() {
}
@Override
public void onClickTitleCtv() {
}
@Override
public void onClickRightCtv() {
}
@Override
public void onClickRightSecondaryCtv() {
}
});
}
@Override
public void onFragmentInteraction(Uri uri) {
}
}
我得到了这个代码,比如grab和ubber
找车
. 但是,当我构建它时出现了一些错误,请帮帮我!!!我开始使用 java 和 android 应用程序。
解决方案
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.uit.huydaoduc.hieu.chi.hhapp"
minSdkVersion 21
targetSdkVersion 26
multiDexEnabled = true
versionCode 3
versionName "1.0.6"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
lintOptions {
checkReleaseBuilds false
abortOnError false
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
targetCompatibility 1.8
sourceCompatibility 1.8
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
//noinspection GradleCompatible
implementation 'com.android.support:appcompat-v7:26.+'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.android.support:support-v4:28.0.0'
implementation 'com.google.android.gms:play-services-plus:15.0.1'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
implementation 'com.github.d-max:spots-dialog:0.7@aar'
implementation 'com.rengwuxian.materialedittext:library:2.1.4'
implementation 'uk.co.chrisjenx:calligraphy:2.3.0'
implementation 'com.android.support:cardview-v7:28.+'
implementation 'com.google.android.gms:play-services-ads:15.0.1'
implementation 'com.squareup.retrofit2:retrofit:2.3.0'
implementation 'com.squareup.retrofit2:converter-scalars:2.3.0'
implementation 'com.squareup.retrofit2:converter-gson:2.3.0'
implementation 'de.hdodenhof:circleimageview:2.2.0'
//Manager/place
implementation 'com.google.maps.android:android-maps-utils:0.4.4'
// login activity
implementation "com.mikepenz:iconics-core:3.0.2@aar"
implementation 'com.mikepenz:fontawesome-typeface:5.0.6.0@aar'
// Location
implementation 'com.google.android.gms:play-services-location:15.0.1'
implementation 'com.google.android.gms:play-services-maps:15.0.1'
implementation 'com.google.android.gms:play-services-places:15.0.1'
// for firebase
implementation platform('com.google.firebase:firebase-bom:27.1.0')
implementation 'com.google.firebase:firebase-analytics'
implementation 'com.firebase:geofire-android:2.1.2'
implementation 'com.google.firebase:firebase-core:12.0.1'
implementation 'com.google.firebase:firebase-database:12.0.1'
implementation 'com.google.firebase:firebase-messaging:12.0.1'
implementation 'com.google.firebase:firebase-core:12.0.1'
implementation 'com.google.firebase:firebase-auth:12.0.1'
implementation 'com.google.firebase:firebase-messaging:12.0.1'
// Facebook, Google login support is required
implementation 'com.facebook.android:facebook-android-sdk:4.27.0'
implementation 'com.google.android.gms:play-services-auth:15.0.1'
// more...
implementation 'com.android.support:design:28.1.0' // support design
implementation 'com.rengwuxian.materialedittext:library:2.1.4' // material edittext
implementation 'uk.co.chrisjenx:calligraphy:2.3.0' // custom font for all view
implementation 'com.android.support:cardview-v7:28.1.0'
implementation 'com.android.support:appcompat-v7:28.1.0'
implementation 'com.android.support:customtabs:28.0.0'
implementation 'com.android.support:design:28.0.0'
implementation 'com.android.support:support-v13:+'
implementation 'androidx.legacy:legacy-support-v13:1.0.0'
implementation 'androidx.viewpager:viewpager:1.0.0'
// process bar
implementation 'me.zhanghai.android.materialprogressbar:library:1.4.2'
implementation 'com.lsjwzh:materialloadingprogressbar:0.5.8-RELEASE'
// action bar
implementation 'cn.bingoogolapple:bga-titlebar:1.0.8'
// radius button
implementation 'com.rilixtech:materialfancybuttons:1.8.7'
// Date & Time picker
implementation 'com.wdullaer:materialdatetimepicker:3.6.0'
// loading view
implementation 'com.wang.avi:library:2.1.3'
// recycler view
implementation 'com.github.CymChad:BaseRecyclerViewAdapterHelper:2.9.38'
implementation 'com.android.support:cardview-v7:28.1.0'
// alert dialog
implementation 'com.afollestad.material-dialogs:core:0.9.6.0'
// Top right menu
implementation 'com.zaaach:toprightmenu:1.1.2'
// Header For layout
implementation 'com.scwang.smartrefresh:SmartRefreshLayout:1.1.0-alpha-5'
implementation 'com.scwang.smartrefresh:SmartRefreshHeader:1.1.0-alpha-5'
// Tab
implementation 'com.ogaclejapan.smarttablayout:library:1.6.1@aar'
implementation 'com.ogaclejapan.smarttablayout:utils-v4:1.6.1@aar'
implementation 'lib.kingja.switchbutton:switchbutton:1.1.7'
// Hieu
implementation 'com.rilixtech:materialfancybuttons:1.8.7'
implementation 'com.github.dimorinny:floating-text-button:0.0.4'
//about
implementation 'com.github.daniel-stoneuk:material-about-library:2.3.0'
implementation 'com.github.jrvansuita:MaterialAbout:+'
implementation 'com.android.support:support-annotations:28.0.0'
implementation 'com.intellij:annotations:+@jar'
//Hung
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
implementation 'androidx.constraintlayout:constraintlayout-compose:1.0.0-alpha05'
implementation 'com.google.android.gms:play-services-maps:16.1.0'
implementation 'com.android.support:support-fragment:28.0.+'
implementation 'com.ogaclejapan.smarttablayout:library:1.7.0@aar'
}
// Add to the bottom of the file
apply plugin: 'com.google.gms.google-services'
这是我的 build.gradle
推荐阅读
- azure - 如何使用 Azure 应用服务来缓解不断增长的保留成本?
- c - 如何将 CMake 的输出重定向到文件而不是 windows cmd 提示符
- php - 使用 $pdoObject->execute() 绑定参数有效,但 bindValue() 无效
- c++ - 为什么“cin”在 EOF 之后不再起作用?
- javascript - 将变量比较分配给 if/else 语句
- javascript - 工具提示在 d3 图表中开箱即用
- c# - WPF 应用程序的不同行为:IDE 调试与直接运行可执行文件
- symfony - 数据库中缺少属性
- javascript - 如何选择最接近随机数的整数?
- php - PHP 脚本 - 跟踪整体脚本执行时间 (curl)