Configure build.gradle

0

Can you help me configure the build.gradle of my hybrid application?

Not running on android 7 Nougat It is an application that loads a website with mXWalkView. It is working perfectly on android 6 Marshmallow, but above not.

link

build.gradle

    apply plugin: 'com.android.application'



List<String> dirs = [
        'main',     // main sample code; look here for the interesting stuff.
        'common',   // components that are reused by multiple samples
        'template'] // boilerplate code that is generated by the sample template 
process


repositories {
    mavenLocal()
    maven {
        url 
 'https://download.01.org/crosswalk/releases/crosswalk/android/maven2'
    }
}

android {
     signingConfigs {
        config {
            keyAlias 'key1'
            keyPassword 'Marcos&@*34134'
            storeFile file('C:/Users/marco/.android/debug.keystore')
            storePassword 'android'
        }
    }
    compileSdkVersion 27
    buildToolsVersion '27.0.3'
    defaultConfig {
        applicationId "net.panomaps"
        minSdkVersion 17
        targetSdkVersion 27
        versionCode 24
        versionName "5.2.5"
        multiDexEnabled true
        testInstrumentationRunner 
"android.support.test.runner.AndroidJUnitRunner"
        javaCompileOptions {
            annotationProcessorOptions {
                includeCompileClasspath true
            }
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 
'proguard-rules.pro'
            signingConfig signingConfigs.config
            debuggable false
        }
        debug {
            signingConfig signingConfigs.config
            debuggable true
        }
    }
    splits {
        // Screen density split settings
        density {

            // Enable or disable the density split mechanism
            enable false

            // Exclude these densities from splits
            exclude "ldpi", "tvdpi", "xxxhdpi", "400dpi", "560dpi"
        }
    }
    sourceSets {
        main {
             dirs.each { dir ->
                java.srcDirs "src/${dir}/java"
                res.srcDirs "src/${dir}/res"
                assets.srcDirs = ['src/main/assets/']
            }
        }
        androidTest.setRoot('tests')
        androidTest.java.srcDirs = ['tests/src']

    }
}


dependencies {
    implementation 'com.google.firebase:firebase-core:11.8.0'
    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:27.0.3'
    compile 'com.android.support:support-v4:27.0.3'
    compile 'com.android.support:design:27.0.3'
    compile 'com.android.support.constraint:constraint-layout:1.0.2'
    compile 'pl.droidsonroids.gif:android-gif-drawable:1.1.7'
    testCompile 'junit:junit:4.12'
    compile 'com.google.android.gms:play-services-ads:11.8.0'
    compile 'com.squareup.picasso:picasso:2.5.2'
    compile 'com.facebook.android:facebook-android-sdk:4.28.0'
    compile 'com.jakewharton:butterknife:8.8.1'
    annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'
    compile 'com.squareup.picasso:picasso:2.5.2'
    compile 'org.xwalk:xwalk_core_library:23.53.589.4'
    compile 'com.google.firebase:firebase-messaging:11.8.0'
    compile 'com.android.support:multidex:1.0.2'
    compile 'com.github.jgabrielfreitas:BlurImageView:1.0.1'
}

configurations.all {
    resolutionStrategy.eachDependency { DependencyResolveDetails details ->
        def requested = details.requested
        if (requested.group == 'com.android.support') {
            if (!requested.name.startsWith("multidex")) {
                details.useVersion '27.0.3'
            }
        }
    }
}

apply plugin: 'com.google.gms.google-services'

Activity.class

package net.panomaps;


import android.annotation.SuppressLint;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.net.Uri;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.design.widget.NavigationView;
import android.support.v4.view.GravityCompat;
import android.support.v4.view.ViewPager;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.ActionBarDrawerToggle;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.ContextThemeWrapper;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.ProgressBar;


import net.panomaps.animation.CubeOutTransformer;

import org.xwalk.core.XWalkResourceClient;
import org.xwalk.core.XWalkView;


public class WebsiteActivity extends AppCompatActivity
    implements NavigationView.OnNavigationItemSelectedListener {

private ProgressBar progressbar;
private FrameLayout frameLayout;

private XWalkView mXWalkView;

@SuppressLint({"SetJavaScriptEnabled", "JavascriptInterface"})
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_website);

    Toolbar toolbar = findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    DrawerLayout drawer = findViewById(R.id.drawer_layout);
    ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
            this, drawer, toolbar, R.string.navigation_drawer_open, 
R.string.navigation_drawer_close);
    drawer.addDrawerListener(toggle);
    toggle.syncState();

    NavigationView navigationView = findViewById(R.id.nav_view);
    navigationView.setNavigationItemSelectedListener(this);


    frameLayout = findViewById(R.id.frameLayout);
    progressbar = findViewById(R.id.progressBar);

    progressbar.setMax(100);


    mXWalkView = findViewById(R.id.activity_main);

    mXWalkView.load("https://panomaps.net/", null);

    mXWalkView.setResourceClient(new XWalkResourceClient(mXWalkView) {
        public void onProgressChanged(XWalkView view, int progress) {
            frameLayout.setVisibility(View.VISIBLE);
            progressbar.setProgress(progress);

            setTitle("Carregando...");

            if (progress == 100) {
                frameLayout.setVisibility(View.GONE);
                setTitle(view.getTitle());
            }
            super.onProgressChanged(view, progress);
        }
    });

    progressbar.setProgress(0);

    if (!haveNetworkConnection()) {
        android.app.AlertDialog.Builder Checkbuilder = new 
android.app.AlertDialog.Builder(WebsiteActivity.this);
        Checkbuilder.setMessage("Por favor conecte-se à internet!");
        android.app.AlertDialog alert = Checkbuilder.create();
        alert.show();
    } else {
        mXWalkView.load("https://panomaps.net/", null);
    }
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.menu_main, menu);
    return true;
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {

    int id = item.getItemId();

    if (id == R.id.action_settings) {
        mXWalkView.load("https://panomaps.net/", null);

    } else if (id == R.id.nav_login) {
        mXWalkView.load("https://panomaps.net/login/", null);

    } else if (id == R.id.nav_information) {
        startActivity(new Intent(getApplicationContext(), 
AboutActivity.class));

    } else if (id == R.id.nav_exit) {
        finish();
    }
    return super.onOptionsItemSelected(item);
}

@SuppressWarnings("StatementWithEmptyBody")
@Override
public boolean onNavigationItemSelected(@NonNull MenuItem item) {
    // Handle navigation view item clicks here.
    int id = item.getItemId();

    if (id == R.id.nav_home) {
        mXWalkView.load("https://panomaps.net/", null);

    } else if (id == R.id.nav_login) {
        mXWalkView.load("https://panomaps.net/login/", null);

    } else if (id == R.id.nav_gallery) {
        startActivity(new Intent(getApplicationContext(), 
ImageSlideActivity.class));

    } else if (id == R.id.nav_fanpage) {
        mXWalkView.load("https://www.facebook.com/panomaps/", null);


    } else if (id == R.id.nav_weather) {
        mXWalkView.load("http://tempo.clic.com.br/sp/panorama", null);

    } else if (id == R.id.nav_share) {
        Intent intent = new Intent(Intent.ACTION_VIEW);

intent.setData(Uri.parse("https://play.google.com/store/apps/details?
id=net.panomaps&hl=pt"));
        startActivity(intent);

    } else if (id == R.id.nav_send) {
        Intent shareIntent = new Intent(Intent.ACTION_SEND);
        shareIntent.setType("text/plain");
        shareIntent.putExtra(Intent.EXTRA_TEXT, mXWalkView.getUrl());
        startActivity(Intent.createChooser(shareIntent, "Compartilhar esta 
página!"));

    }

    DrawerLayout drawer = findViewById(R.id.drawer_layout);
    drawer.closeDrawer(GravityCompat.START);
    return true;

}

private boolean haveNetworkConnection() {
    ConnectivityManager connectivityManager = (ConnectivityManager) 
this.getSystemService(Context.CONNECTIVITY_SERVICE);
    NetworkInfo activeNetworkInfo = connectivityManager != null ? 
connectivityManager.getActiveNetworkInfo() : null;
    return activeNetworkInfo != null;

}

@Override
public void onBackPressed() {
    ContextThemeWrapper ctw = new ContextThemeWrapper(this, 
R.style.PanomapsTheme);
    AlertDialog.Builder builder = new AlertDialog.Builder(ctw);
    builder.setMessage("Deseja encerrar?")
            .setCancelable(false)
            .setPositiveButton("sim", new DialogInterface.OnClickListener() 
{
                public void onClick(DialogInterface dialog, int id) {
                    finish();
                }
            })
            .setNegativeButton("Não", new DialogInterface.OnClickListener() 
{
                public void onClick(DialogInterface dialog, int id) {
                    dialog.cancel();
                }
            });
    AlertDialog alert = builder.create();
    alert.show();
}

@Override
protected void onDestroy() {
    // TODO Auto-generated method stub
    super.onDestroy();
}
    
asked by anonymous 18.01.2018 / 22:31

0 answers