Thank you for the help!
- Regarding the V27 or 28 or AndroidX gradles, V27 downloaded properly, I am very impressed with AIDE, this is the gradles I used:
Master
apply plugin: ‘com.android.application’
android {
compileSdkVersion 21
buildToolsVersion “21.1.0”
defaultConfig {
applicationId "upiva.spaza.app"
minSdkVersion 14
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: ‘libs’, include: [’*.jar’])
}
Project gradle
apply plugin: ‘com.android.application’
android {
compileSdkVersion 27
buildToolsVersion “27.1.0”
defaultConfig {
applicationId "upiva.spaza.app"
minSdkVersion 18
targetSdkVersion 27
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation ‘com.android.support:appcompat-v7:27.1.0’
implementation ‘com.android.support:support-v4:27.0.0’
implementation fileTree(dir: ‘libs’, include: [’.jar’])
compile fileTree(dir: ‘libs’, include: [’.jar’])
}
that seemingly installed correctly!
However when I extend a MyActivity from AppCompatActivity it crashes!
- Regarding the logging, I’m on a non-rooted device - no matter how hard I try I just can’t see the logcat.
So I created this logger called Lgx - that logs to the Android cache and I have no problem viewing my own apps logs.
Anybody feel free to use it if you think it can help, just call Lgx.init( , , msg… ) from a custom Application class.
package upiva.spaza.app.utl.gen;
import android.content.Context;
import android.util.Log;
import java.io.File;
import java.io.FileWriter;
import java.util.Date;
public enum Lgx {
/// Constants
// never trust enum.ordinsls!
FAIL( 0 ),
WARN( 1 ),
NWTF( 2 ),
DBUG( 3 ),
INFO( 4 ),
FINE( 5 ),
MORE( 6 ),
MOST( 7 ),
VRBS( 9 );
private static int sMask = 0;
private Lgx( final int mask ) {
sMask = mask;
}
/// Inners
// fluent arg. evaluator
public static class Eval {
/// Members
private final StackTraceElement mElem;
/// Construction
private Eval() {
super();
mElem = _stax_( 2 );
}
/// Methods
public Eval notNull( final String para, final Object data ) {
if( data == null ) {
_logx_( null, mElem, String.format( "Argument '%s' required!", para ) );
}
return this;
}
public Eval notNull( final String para, final Object[] data ) {
if( data == null ) {
_logx_( null, mElem, String.format( "Array argument '%s' of not zero-length required!", para ) );
}
return this;
}
public Eval notMinVal( final String para, final long data, final long minv ) {
if( data < minv ) {
_logx_( null, mElem, String.format( "Argument '%s' of min-value( %d ) required!", para, minv ) );
}
return this;
}
public Eval notMaxVal( final String para, final long data, final long maxv ) {
if( data > maxv ) {
_logx_( null, mElem, String.format( "Argument '%s' of max-value( %d ) required!", para, maxv ) );
}
return this;
}
public Eval notMinMaxVal( final String para, final long data, final long minv, final long maxv ) {
if( ( data < minv ) || ( data > maxv ) ) {
_logx_( null, mElem, String.format( "Argument '%s' of min-value( %d ) - max-value( %d ) required!", para, minv, maxv ) );
}
return this;
}
public Eval notMinDbl( final String para, final double data, final double minv ) {
if( data < minv ) {
_logx_( null, mElem, String.format( "Argument '%s' of min-value( %d ) required!", para, minv ) );
}
return this;
}
public Eval notMaxDbl( final String para, final double data, final double maxv ) {
if( data > maxv ) {
_logx_( null, mElem, String.format( "Argument '%s' of max-value( %d ) required!", para, maxv ) );
}
return this;
}
public Eval notMinMaxDbl( final String para, final double data, final double minv, final double maxv ) {
if( ( data < minv ) || ( data > maxv ) ) {
_logx_( null, mElem, String.format( "Argument '%s' of min-value( %d ) - max-value( %d ) required!", para, minv, maxv ) );
}
return this;
}
public Eval notText( final String para, final String text ) {
if( ( text == null ) || text.isEmpty() ) {
_logx_( null, mElem, String.format( "Argument '%s' required!", para ) );
}
return this;
}
public Eval notMinLen( final String para, final String text, final long minl ) {
if( ( text == null ) || text.isEmpty() || ( text.length() < minl ) ) {
_logx_( null, mElem, String.format( "Argument '%s' of min-length( %d ) required!", para, minl ) );
}
return this;
}
public Eval notMaxLen( final String para, final String text, final long maxl ) {
if( ( text == null ) || text.isEmpty() || ( text.length() > maxl ) ) {
_logx_( null, mElem, String.format( "Argument '%s' of max-length( %d ) required!", para, maxl ) );
}
return this;
}
public Eval notMinMaxLen( final String para, final String text, final long minl, final long maxl ) {
if( ( text == null ) || text.isEmpty() || ( text.length() < minl) || ( text.length() > maxl ) ) {
_logx_( null, mElem, String.format( "Argument '%s' of min-length( %d ) - max-length( %d ) required!", para, minl, maxl ) );
}
return this;
}
}//-Eval
/// Members
private static File sFile = null;
private static Lgx sMode = Lgx.DBUG;
/// Construction
private Lgx( ) {}
/// Helpers
private static StackTraceElement stax( final int indx ) {
StackTraceElement[] _arry = null;
try {
throw new Exception( “-hack-” );
} catch( Exception e ) {
_arry = e.getStackTrace();
}
return _arry[ indx ];
}
private static String logx( final Lgx mode, final StackTraceElement stax, final String msgs ) {
// always log fail + warn + nwtf
if( mode.sMask > NWTF.sMask ) {
if( mode.sMask > sMode.sMask )
return “”;
}
// prep message
final String text = String.format( “%s: @%s [%d]\n\t%s”, mode.name(), stax.getClassName(), stax.getLineNumber(), msgs );
if( sFile != null ) {
// append
try {
final FileWriter w = new FileWriter( sFile, true );
w.append( text );
w.append( “\n” );
w.flush();
w.close();
} catch( Exception e ) {
e.printStackTrace();
Log.e( “Lgx.logx”, e.toString() );
}
}
// droid logging
switch( mode ) {
case FAIL:
Log.e( “Lgx.logx”, text );
throw new RuntimeException( text );
case WARN:
Log.w( “Lgx.logx”, text );
return text;
case NWTF:
Log.wtf( “Lgx.logx”, text );
return text;
case DBUG:
Log.d( “Lgx.logx”, text );
return text;
case INFO:
case FINE:
case MORE:
case MOST:
Log.i( “Lgx.logx”, text );
return text;
case VRBS:
Log.v( “Lgx.logx”, text );
return text;
default:
throw new RuntimeException( "Lgx; Unknown mask: " + text );
}
}
/// Utilities
public static void fail( final String frmt, final Object… args ) {
logx( Lgx.FAIL, stax( 2 ), String.format( frmt, args ) );
}//-fail
public static void fail( final Throwable e ) {
final StackTraceElement x = ( e != null ) ? e.getStackTrace()[ 1 ] : stax( 2 );
logx( Lgx.FAIL, x, x.toString() );
}//-fail
public static void fail( final Throwable e, final String frmt, final Object… args ) {
final StackTraceElement x = ( e != null ) ? e.getStackTrace()[ 1 ] : stax( 2 );
String _text = String.format( frmt, args );
_text = _text + "\nDue: " + x.toString();
logx( Lgx.FAIL, x, _text );
}//-fail
public static String warn( final String frmt, final Object… args ) {
return logx( Lgx.WARN, stax( 2 ), String.format( frmt, args ) );
}//-warn
public static String nwtf( final String frmt, final Object… args ) {
return logx( Lgx.NWTF, stax( 2 ), String.format( frmt, args ) );
}//-most
public static String dbug( final String frmt, final Object… args ) {
return logx( Lgx.DBUG, stax( 2 ), String.format( frmt, args ) );
}//-dbug
public static String info( final String frmt, final Object… args ) {
return logx( Lgx.INFO, stax( 2 ), String.format( frmt, args ) );
}//-info
public static String fine( final String frmt, final Object… args ) {
return logx( Lgx.FINE, stax( 2 ), String.format( frmt, args ) );
}//-info
public static String more( final String frmt, final Object… args ) {
return logx( Lgx.MORE, stax( 2 ), String.format( frmt, args ) );
}//-info
public static String most( final String frmt, final Object… args ) {
return logx( Lgx.MOST, stax( 2 ), String.format( frmt, args ) );
}//-info
public static String vrbs( final String frmt, final Object… args ) {
return logx( Lgx.VRBS, stax( 2 ), String.format( frmt, args ) );
}//-most
public static Eval eval() {
return new Eval();
}//-eval
/// Factory
public static void init( final Context cntx, final Lgx mode, final String frmt, final Object… args ) {
if( cntx == null )
throw new IllegalArgumentException( “Lgx.init; Context argument required !” );
sMode = mode;
if( sFile == null ) {
final Date date = new Date( System.currentTimeMillis( ) );
String _name = String.format( “%tF%tR.txt”, date, date );
_name = _name.replace( “-”, “” ).replace( “:”, “” );
File _file = cntx.getExternalCacheDir();
sFile = new File( _file, _name );
}
logx( Lgx.INFO, stax( 2 ), String.format( frmt, args ) );
}//-init
public static void shut( final String frmt, final Object… args ) {
logx( Lgx.INFO, stax( 2 ), String.format( frmt, args ) );
//sFile = null;
}//-shut
}//-eoc
l should very much appreciate it if someone can publish a grsdle.build for a minimal working set for AndroidX.