安卓移动应用开发

1:错误提示:Could not find com.android.tools.build:gradle:3.5解决方法:我有google()都在buildscript和allprojects但是它仍然向我展示了Could not find gradle-3.5.3误差最后我加入了maven { url "https://maven.google.com" }修正了错误!项目级别build.gradle:buildscript { ext { buildToo..
摘要由CSDN通过智能技术生成

1:错误提示:Could not find com.android.tools.build:gradle:3.5

解决方法:

我有google()都在buildscriptallprojects但是它仍然向我展示了Could not find gradle-3.5.3误差
最后我加入了maven { url "https://maven.google.com" }修正了错误!

项目级别build.gradle:

buildscript {
    ext {
        buildToolsVersion = "29.0.2"
        minSdkVersion = 16
        compileSdkVersion = 29
        targetSdkVersion = 29
    }
    repositories {
        maven { url "https://maven.google.com" }  // <= this line
        google()
        jcenter()
    }
    dependencies {
        classpath("com.android.tools.build:gradle:3.5.3")
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        maven { url "https://maven.google.com" }  // <= this line
        mavenLocal()
        maven {
            // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
            url("$rootDir/../node_modules/react-native/android")
        }
        maven {
            // Android JSC is installed from npm
            url("$rootDir/../node_modules/jsc-android/dist")
        }

        google()
        jcenter()
        maven { url 'https://www.jitpack.io' }
    }
}

2:我正在开发一个应用程序。在我的应用程序中,代码中没有错误,但是当我试图运行我的项目时,它会给出以下错误。 

错误提示:

Error:(1, 1) A problem occurred evaluating project ':app'.

Failed to apply plugin [id 'com.android.application']

Could not create plugin of type 'AppPlugin'.

解决方法:

在我的项目中有一个.gradle文件夹,该文件夹缓存了我使用的上一个Gradle版本(5.4.1),Gradle继续使用而不是新下载的(5.6.4)。

简单地说:

  1. Android Studio
  2. 删除项目中的旧版本文件夹。
  3. 重新启动 Android Studio。一切都应该正常工作

如果这不起作用,您还可以尝试以下方法:

  • 删除Project.gradle文件夹中的所有版本,因此只有新版本才会被重新下载,就像重新打开IDE时一样。
  • 检查Gradle构建版本的项目设置,并确保它设置为最新版本。
  • 检查其他模块是否使用较早版本的Gradle构建。可以使用项目搜索(Ctrl+Shift+F)"distributionUrl"确保所有模块都有最新版本。
  • 删除.gradle/caches在根级文件夹下,通常C://Users/{you}/.gradle
  • 试一试gradle build --stacktrace--info--scan或者--debug在你的AS终端获得帮助和更多的信息来调试你的问题。

3:如何通过单击左右箭头获取选定日期或当日日期的下一个日期的前一个日期:

Calendar c = Calendar.getInstance();
//for selected date add this line c.set(2021,2,2)
SimpleDateFormat df = new SimpleDateFormat("dd-MMM-yyyy");
String formattedDate = df.format(c.getTime());
textview.setText(formattedDate);

For next date

previous.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            c.add(Calendar.DATE, -1);
            formattedDate = df.format(c.getTime());
            textview.setText(formattedDate);
         }
      });

For previous date

next.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            c.add(Calendar.DATE, 1);
            formattedDate = df.format(c.getTime());
            textview.setText(formattedDate);
        }
    });

 4:Android 沉浸式状态栏攻略  让你的状态栏变色

三、实现半透明状态栏
因为本例使用了NavigationView,所以布局代码稍多,当然如果你不需要,可以自己进行筛减。

注意引入相关依赖:

 compile 'com.android.support:appcompat-v7:22.2.1'
 compile 'com.android.support:support-v4:22.2.1'
 compile 'com.android.support:design:22.2.0'



(一)colors.xml 和 styles.xml
首先我们定义几个颜色:

res/values/color.xml

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <color name="primary">#FF03A9F4</color>
    <color name="primary_dark">#FF0288D1</color>
    <color name="status_bar_color">@color/primary_dark</color>
</resources>

下面定义几个styles.xml

注意文件夹的路径:

values/styles.xml

<resources>
    <style name="BaseAppTheme" parent="Theme.AppCompat.Light.NoActionBar">
        <!-- Customize your theme here. -->
        <item name="colorPrimary">@color/primary</item>
        <item name="colorPrimaryDark">@color/primary_dark</item>
        <item name="colorAccent">#FF4081</item>
    </style>

    <!-- Base application theme. -->
    <style name="AppTheme" parent="@style/BaseAppTheme">
    </style>
</resources>

values-v19

<resources>

    <style name="AppTheme" parent="@style/BaseAppTheme">
        <item name="android:windowTranslucentStatus">true</item>
    </style>
</resources>

ok,这个没撒说的。注意我们的主题是基于NoActionBar的,android:windowTranslucentStatus这个属性是v19开始引入的。

(二)布局文件

activity_main.xml

<android.support.v4.widget.DrawerLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    >


    <LinearLayout
        android:id="@+id/id_main_content"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">

        <android.support.v7.widget.Toolbar
            android:id="@+id/id_toolbar"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="?attr/colorPrimary"
            android:fitsSystemWindows="true"
            app:popupTheme="@style/ThemeOverlay.AppCompat.Light"/>


        <TextView
            android:id="@+id/id_tv_content"
            android:layout_width="match_pa
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值