Reputation: 93
My project was running well (and the backup project still doesn't produce this error) but when I added layout for Conact_Us page it produced this error. (Contact us activity is not throwing any error) following is my Gradle build Message
Information:Gradle tasks [:app:assembleDebug] Observed package id 'add-ons;addon-google_apis-google-23' in inconsistent location 'C:\Users\DELL\AppData\Local\Android\Sdk\add-ons\addon-google_apis-google-23-1' (Expected 'C:\Users\DELL\AppData\Local\Android\Sdk\add-ons\addon-google_apis-google-23') Already observed package id 'add-ons;addon-google_apis-google-23' in 'C:\Users\DELL\AppData\Local\Android\Sdk\add-ons\addon-google_apis-google-23'. Skipping duplicate at 'C:\Users\DELL\AppData\Local\Android\Sdk\add-ons\addon-google_apis-google-23-1' :app:preBuild UP-TO-DATE :app:preDebugBuild UP-TO-DATE :app:checkDebugManifest :app:preReleaseBuild UP-TO-DATE :app:prepareComAndroidSupportAnimatedVectorDrawable2400Beta1Library UP-TO-DATE :app:prepareComAndroidSupportAppcompatV72400Beta1Library UP-TO-DATE :app:prepareComAndroidSupportDesign2400Beta1Library UP-TO-DATE :app:prepareComAndroidSupportMediarouterV72300Library UP-TO-DATE :app:prepareComAndroidSupportMultidex101Library UP-TO-DATE :app:prepareComAndroidSupportRecyclerviewV72400Beta1Library UP-TO-DATE :app:prepareComAndroidSupportSupportV42400Library UP-TO-DATE :app:prepareComAndroidSupportSupportVectorDrawable2400Beta1Library UP-TO-DATE :app:prepareComDaimajiaSliderLibrary115Library UP-TO-DATE :app:prepareComGoogleAndroidGmsPlayServices902Library UP-TO-DATE :app:prepareComGoogleAndroidGmsPlayServicesAds902Library UP-TO-DATE :app:prepareComGoogleAndroidGmsPlayServicesAdsLite902Library UP-TO-DATE :app:prepareComGoogleAndroidGmsPlayServicesAnalytics902Library UP-TO-DATE :app:prepareComGoogleAndroidGmsPlayServicesAnalyticsImpl902Library UP-TO-DATE :app:prepareComGoogleAndroidGmsPlayServicesAppindexing902Library UP-TO-DATE :app:prepareComGoogleAndroidGmsPlayServicesAppinvite902Library UP-TO-DATE :app:prepareComGoogleAndroidGmsPlayServicesAuth902Library UP-TO-DATE :app:prepareComGoogleAndroidGmsPlayServicesAuthBase902Library UP-TO-DATE :app:prepareComGoogleAndroidGmsPlayServicesBase902Library UP-TO-DATE :app:prepareComGoogleAndroidGmsPlayServicesBasement902Library UP-TO-DATE :app:prepareComGoogleAndroidGmsPlayServicesCast902Library UP-TO-DATE :app:prepareComGoogleAndroidGmsPlayServicesDrive902Library UP-TO-DATE :app:prepareComGoogleAndroidGmsPlayServicesFitness902Library UP-TO-DATE :app:prepareComGoogleAndroidGmsPlayServicesGames902Library UP-TO-DATE :app:prepareComGoogleAndroidGmsPlayServicesGcm902Library UP-TO-DATE :app:prepareComGoogleAndroidGmsPlayServicesIdentity902Library UP-TO-DATE :app:prepareComGoogleAndroidGmsPlayServicesIid902Library UP-TO-DATE :app:prepareComGoogleAndroidGmsPlayServicesLocation902Library UP-TO-DATE :app:prepareComGoogleAndroidGmsPlayServicesMaps902Library UP-TO-DATE :app:prepareComGoogleAndroidGmsPlayServicesNearby902Library UP-TO-DATE :app:prepareComGoogleAndroidGmsPlayServicesPanorama902Library UP-TO-DATE :app:prepareComGoogleAndroidGmsPlayServicesPlus902Library UP-TO-DATE :app:prepareComGoogleAndroidGmsPlayServicesSafetynet902Library UP-TO-DATE :app:prepareComGoogleAndroidGmsPlayServicesTagmanager902Library UP-TO-DATE :app:prepareComGoogleAndroidGmsPlayServicesTagmanagerApi902Library UP-TO-DATE :app:prepareComGoogleAndroidGmsPlayServicesTasks902Library UP-TO-DATE :app:prepareComGoogleAndroidGmsPlayServicesVision902Library UP-TO-DATE :app:prepareComGoogleAndroidGmsPlayServicesWallet902Library UP-TO-DATE :app:prepareComGoogleAndroidGmsPlayServicesWearable902Library UP-TO-DATE :app:prepareComGoogleFirebaseFirebaseAnalytics902Library UP-TO-DATE :app:prepareComGoogleFirebaseFirebaseAnalyticsImpl902Library UP-TO-DATE :app:prepareComGoogleFirebaseFirebaseAuth902Library UP-TO-DATE :app:prepareComGoogleFirebaseFirebaseAuthCommon902Library UP-TO-DATE :app:prepareComGoogleFirebaseFirebaseAuthModule902Library UP-TO-DATE :app:prepareComGoogleFirebaseFirebaseCommon902Library UP-TO-DATE :app:prepareComGoogleFirebaseFirebaseConfig902Library UP-TO-DATE :app:prepareComGoogleFirebaseFirebaseCrash902Library UP-TO-DATE :app:prepareComGoogleFirebaseFirebaseDatabase902Library UP-TO-DATE :app:prepareComGoogleFirebaseFirebaseDatabaseConnection902Library UP-TO-DATE :app:prepareComGoogleFirebaseFirebaseIid902Library UP-TO-DATE :app:prepareComGoogleFirebaseFirebaseMessaging902Library UP-TO-DATE :app:prepareComGoogleFirebaseFirebaseStorage902Library UP-TO-DATE :app:prepareComGoogleFirebaseFirebaseStorageCommon902Library UP-TO-DATE :app:prepareDebugDependencies :app:compileDebugAidl UP-TO-DATE :app:compileDebugRenderscript UP-TO-DATE :app:generateDebugBuildConfig UP-TO-DATE :app:mergeDebugShaders UP-TO-DATE :app:compileDebugShaders UP-TO-DATE :app:generateDebugAssets UP-TO-DATE :app:mergeDebugAssets UP-TO-DATE :app:generateDebugResValues UP-TO-DATE :app:generateDebugResources UP-TO-DATE :app:mergeDebugResources UP-TO-DATE :app:processDebugManifest UP-TO-DATE :app:processDebugResources UP-TO-DATE :app:generateDebugSources UP-TO-DATE :app:incrementalDebugJavaCompilationSafeguard UP-TO-DATE :app:compileDebugJavaWithJavac :app:compileDebugJavaWithJavac - is not incremental (e.g. outputs have changed, no previous execution, etc.). E:\Optasia\Optasia2\app\src\main\java\com\example\dell\optasia\WelcomeActivity.java Error:(81, 18) error: cannot find symbol method addOnPageChangeListener(OnPageChangeListener) Note: Some input files use or override a deprecated API. Note: Recompile with -Xlint:deprecation for details. :app:compileDebugJavaWithJavac FAILED Error:Execution failed for task ':app:compileDebugJavaWithJavac'. Compilation failed; see the compiler error output for details. Information:BUILD FAILED Information:Total time: 9.781 secs Information:2 errors Information:0 warnings Information:See complete output in console
here is my code where the erro is occurring
package com.example.dell.optasia;
import android.content.Context;
import android.content.Intent;
import android.graphics.Color;
import android.os.Build;
import android.os.Bundle;
import android.support.v4.view.PagerAdapter;
import android.support.v4.view.ViewPager;
import android.support.v7.app.AppCompatActivity;
import android.text.Html;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.example.dell.optasia.MainActivity;
import com.example.dell.optasia.R;
public class WelcomeActivity extends AppCompatActivity {
private ViewPager viewPager;
private MyViewPagerAdapter myViewPagerAdapter;
private LinearLayout dotsLayout;
private TextView[] dots;
private int[] layouts;
private Button btnSkip, btnNext;
private PrefManager prefManager;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Checking for first time launch - before calling setContentView()
prefManager = new PrefManager(this);
if (!prefManager.isFirstTimeLaunch()) {
launchHomeScreen();
finish();
}
// Making notification bar transparent
if (Build.VERSION.SDK_INT >= 21) {
getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
}
setContentView(R.layout.activity_welcome);
viewPager = (ViewPager) findViewById(R.id.view_pager);
dotsLayout = (LinearLayout) findViewById(R.id.layoutDots);
btnSkip = (Button) findViewById(R.id.btn_skip);
btnNext = (Button) findViewById(R.id.btn_next);
// layouts of all welcome sliders
// add few more layouts if you want
layouts = new int[]{
R.layout.welcome_slide1,
R.layout.welcome_slide2,
R.layout.welcome_slide3,
R.layout.welcome_slide4};
// adding bottom dots
addBottomDots(0);
// making notification bar transparent
changeStatusBarColor();
myViewPagerAdapter = new MyViewPagerAdapter();
viewPager.setAdapter(myViewPagerAdapter);
viewPager.addOnPageChangeListener(viewPagerPageChangeListener);
btnSkip.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
launchHomeScreen();
}
});
btnNext.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// checking for last page
// if last page home screen will be launched
int current = getItem(+1);
if (current < layouts.length) {
// move to next screen
viewPager.setCurrentItem(current);
} else {
launchHomeScreen();
}
}
});
}
private void addBottomDots(int currentPage) {
dots = new TextView[layouts.length];
int[] colorsActive = getResources().getIntArray(R.array.array_dot_active);
int[] colorsInactive = getResources().getIntArray(R.array.array_dot_inactive);
dotsLayout.removeAllViews();
for (int i = 0; i < dots.length; i++) {
dots[i] = new TextView(this);
dots[i].setText(Html.fromHtml("•"));
dots[i].setTextSize(35);
dots[i].setTextColor(colorsInactive[currentPage]);
dotsLayout.addView(dots[i]);
}
if (dots.length > 0)
dots[currentPage].setTextColor(colorsActive[currentPage]);
}
private int getItem(int i) {
return viewPager.getCurrentItem() + i;
}
private void launchHomeScreen() {
prefManager.setFirstTimeLaunch(false);
startActivity(new Intent(WelcomeActivity.this, HomeScreen.class));
finish();
}
// viewpager change listener
ViewPager.OnPageChangeListener viewPagerPageChangeListener = new ViewPager.OnPageChangeListener() {
@Override
public void onPageSelected(int position) {
addBottomDots(position);
// changing the next button text 'NEXT' / 'GOT IT'
if (position == layouts.length - 1) {
// last page. make button text to GOT IT
btnNext.setText(getString(R.string.start));
btnSkip.setVisibility(View.GONE);
} else {
// still pages are left
btnNext.setText(getString(R.string.next));
btnSkip.setVisibility(View.VISIBLE);
}
}
@Override
public void onPageScrolled(int arg0, float arg1, int arg2) {
}
@Override
public void onPageScrollStateChanged(int arg0) {
}
};
/**
* Making notification bar transparent
*/
private void changeStatusBarColor() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
Window window = getWindow();
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
window.setStatusBarColor(Color.TRANSPARENT);
}
}
/**
* View pager adapter
*/
public class MyViewPagerAdapter extends PagerAdapter {
private LayoutInflater layoutInflater;
public MyViewPagerAdapter() {
}
@Override
public Object instantiateItem(ViewGroup container, int position) {
layoutInflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View view = layoutInflater.inflate(layouts[position], container, false);
container.addView(view);
return view;
}
@Override
public int getCount() {
return layouts.length;
}
@Override
public boolean isViewFromObject(View view, Object obj) {
return view == obj;
}
@Override
public void destroyItem(ViewGroup container, int position, Object object) {
View view = (View) object;
container.removeView(view);
}
}
}
error at viewPager.addOnPageChangeListener(viewPagerPageChangeListener);
following is my Gradle Built
apply plugin: 'com.android.application'
android {
compileSdkVersion 24
buildToolsVersion "23.0.3"
defaultConfig {
applicationId "com.example.dell.optasia"
minSdkVersion 15
targetSdkVersion 24
versionCode 1
versionName "1.0"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.daimajia.slider:library:1.1.5@aar'
androidTestCompile 'junit:junit:4.12'
compile 'com.android.support:support-v4:24.0.0'
compile 'com.android.support:appcompat-v7:24.0.0-beta1'
compile 'com.google.android.gms:play-services:9.0.2'
compile 'com.android.support:design:24.0.0-beta1'
compile 'com.android.support:multidex:1.0.0'
compile 'com.google.android.gms:play-services-ads:9.0.2'
compile 'com.google.android.gms:play-services-auth:9.0.2'
compile 'com.google.android.gms:play-services-gcm:9.0.2'
compile files('E:/Optasia/Optasia2/libs/mail.jar')
compile files('E:/Optasia/Optasia2/libs/android-support-v4.jar')
compile files('E:/Optasia/Optasia2/libs/additionnal.jar')
compile files('E:/Optasia/Optasia2/libs/activation.jar')
}
Upvotes: 0
Views: 756
Reputation: 191725
I suspect you are getting a ViewPager class in your code without the onPageChangeListener method defined.
You'll need to be using this import
android.support.v4.view.ViewPager
I'd also recommend cleaning up your dependencies like this
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.daimajia.slider:library:1.1.5@aar'
androidTestCompile 'junit:junit:4.12'
compile 'com.android.support:design:24.0.0-beta1'
compile 'com.android.support:multidex:1.0.0'
compile 'com.google.android.gms:play-services-ads:9.0.2'
compile 'com.google.android.gms:play-services-auth:9.0.2'
compile 'com.google.android.gms:play-services-gcm:9.0.2'
}
Then, if these files reference your local project, here, then remove the v4 JAR
compile files('E:/Optasia/Optasia2/libs/mail.jar')
compile files('E:/Optasia/Optasia2/libs/android-support-v4.jar')
compile files('E:/Optasia/Optasia2/libs/additionnal.jar')
compile files('E:/Optasia/Optasia2/libs/activation.jar')
Those lines aren't necessary if your jar files are in the libs directory because of this line, which compiles all the jars in the libs.
compile fileTree(include: ['*.jar'], dir: 'libs')
Upvotes: 0
Reputation: 1090
You have added two versions of support library. Remove the jar version as I suspect that should be older version which does not have addOnPageChangeListener
Remove
compile files('E:/Optasia/Optasia2/libs/android-support-v4.jar')
Upvotes: 0