GridView继承自BoxScrollView,BoxScrollView继承自ScrollView
GridView有多种构建函数
GridView
GridView.builder
GridView.count
GridView.custom
GridView.extent
GridView继承自BoxScrollView,BoxScrollView继承自ScrollView
GridView有多种构建函数
GridView
GridView.builder
GridView.count
GridView.custom
GridView.extent
将长度为10位的时间戳(秒级)转换为时间:
1 2 |
select cast(datetime(logtime, 'unixepoch', 'localtime') as text),logcontent from logs |
将长度为13位的时间戳(毫秒级)转换为时间(秒级):
1 2 |
select cast(datetime(logtime/1000, 'unixepoch', 'localtime') as text),logcontent from logs |
将长度为13位的时间戳(毫秒级)转换为时间(毫秒级):
1 2 |
select cast(datetime(logtime/1000, 'unixepoch', 'localtime') as text)||'.'||cast(logtime%1000 as text),logcontent from logs |
执行yarn android出现如下错误
1 2 3 4 5 6 |
yarn : 无法加载文件 d:\nodejs\yarn.ps1,因为在此系统上禁止运行脚本。有关详细信息,请参阅 https:/go.microsoft.com/fwlink/?LinkID=135170 中的 about_Execution_Policies。 所在位置 行:1 字符: 1 + yarn android + ~~~~ + CategoryInfo : SecurityError: (:) [],PSSecurityException + FullyQualifiedErrorId : UnauthorizedAccess |
解决办法:
将项目的原来的gradle版本由5.1.1升级到7.2版本后再编译就报如下错误
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 |
FAILURE: Build completed with 5 failures. 1: Task failed with an exception. ----------- * What went wrong: A problem was found with the configuration of task ':app:checkDebugManifest' (type 'CheckManifest'). - In plugin 'com.android.build.gradle.api.AndroidBasePlugin' type 'com.android.build.gradle.internal.tasks.CheckManifest' property 'manifest' has @Input annotation used on property of type 'File'. Reason: A property of type 'File' annotated with @Input cannot determine how to interpret the file. Possible solutions: 1. Annotate with @InputFile for regular files. 2. Annotate with @InputDirectory for directories. 3. If you want to track the path, return File.absolutePath as a String and keep @Input. Please refer to https://docs.gradle.org/7.2/userguide/validation_problems.html#incorrect_use_of_input_annotation for more details about this problem. * Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights. ============================================================================== 2: Task failed with an exception. ----------- * What went wrong: A problem was found with the configuration of task ':app:createDebugCompatibleScreenManifests' (type 'CompatibleScreensManifest'). - In plugin 'com.android.build.gradle.api.AndroidBasePlugin' type 'com.android.build.gradle.tasks.CompatibleScreensManifest' property 'outputScope' is missing an input or output annotation. Reason: A property without annotation isn't considered during up-to-date checking. Possible solutions: 1. Add an input or output annotation. 2. Mark it as @Internal. Please refer to https://docs.gradle.org/7.2/userguide/validation_problems.html#missing_annotation for more details about this problem. * Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights. ============================================================================== 3: Task failed with an exception. ----------- * What went wrong: A problem was found with the configuration of task ':app:compileDebugShaders' (type 'ShaderCompile'). - In plugin 'com.android.build.gradle.api.AndroidBasePlugin' type 'com.android.build.gradle.tasks.ShaderCompile' property 'sourceDir' is annotated with @InputFiles but missing a normalization strategy. Reason: If you don't declare the normalization, outputs can't be re-used between machines or locations on the same machine, therefore caching efficiency drops significantly. Possible solution: Declare the normalization strategy by annotating the property with either @PathSensitive, @Classpath or @CompileClasspath. Please refer to https://docs.gradle.org/7.2/userguide/validation_problems.html#missing_normalization_annotation for more details about this problem. * Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights. ============================================================================== 4: Task failed with an exception. ----------- * What went wrong: Some problems were found with the configuration of task ':app:signingConfigWriterDebug' (type 'SigningConfigWriterTask'). - In plugin 'com.android.build.gradle.api.AndroidBasePlugin' type 'com.android.build.gradle.internal.tasks.SigningConfigWriterTask' property 'signingConfig.name' is missing an input or output annotation. Reason: A property without annotation isn't considered during up-to-date checking. Possible solutions: 1. Add an input or output annotation. 2. Mark it as @Internal. Please refer to https://docs.gradle.org/7.2/userguide/validation_problems.html#missing_annotation for more details about this problem. - In plugin 'com.android.build.gradle.api.AndroidBasePlugin' type 'com.android.build.gradle.internal.tasks.SigningConfigWriterTask' property 'signingConfig.signingReady' is missing an input or output annotation. Reason: A property without annotation isn't considered during up-to-date checking. Possible solutions: 1. Add an input or output annotation. 2. Mark it as @Internal. Please refer to https://docs.gradle.org/7.2/userguide/validation_problems.html#missing_annotation for more details about this problem. - In plugin 'com.android.build.gradle.api.AndroidBasePlugin' type 'com.android.build.gradle.internal.tasks.SigningConfigWriterTask' property 'signingConfig.storeFile' is annotated with @InputFile but missing a normalization strategy. Reason: If you don't declare the normalization, outputs can't be re-used between machines or locations on the same machine, therefore caching efficiency drops significantly. Possible solution: Declare the normalization strategy by annotating the property with either @PathSensitive, @Classpath or @CompileClasspath. Please refer to https://docs.gradle.org/7.2/userguide/validation_problems.html#missing_normalization_annotation for more details about this problem. * Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights. ============================================================================== 5: Task failed with an exception. ----------- * What went wrong: Some problems were found with the configuration of task ':app:transformNativeLibsWithMergeJniLibsForDebug' (type 'TransformTask'). - In plugin 'com.android.build.gradle.api.AndroidBasePlugin' type 'com.android.build.gradle.internal.pipeline.TransformTask' property 'allSecondaryInputs' is private and annotated with @Internal. Reason: Annotations on private getters are ignored. Possible solutions: 1. Make the getter public. 2. Annotate the public version of the getter. Please refer to https://docs.gradle.org/7.2/userguide/validation_problems.html#private_getter_must_not_be_annotated for more details about this problem. - In plugin 'com.android.build.gradle.api.AndroidBasePlugin' type 'com.android.build.gradle.internal.pipeline.TransformTask' property 'logging' is missing an input or output annotation. Reason: A property without annotation isn't considered during up-to-date checking. Possible solutions: 1. Add an input or output annotation. 2. Mark it as @Internal. Please refer to https://docs.gradle.org/7.2/userguide/validation_problems.html#missing_annotation for more details about this problem. - In plugin 'com.android.build.gradle.api.AndroidBasePlugin' type 'com.android.build.gradle.internal.pipeline.TransformTask' property 'oldSecondaryInputs' is annotated with @InputFiles but missing a normalization strategy. Reason: If you don't declare the normalization, outputs can't be re-used between machines or locations on the same machine, therefore caching efficiency drops significantly. Possible solution: Declare the normalization strategy by annotating the property with either @PathSensitive, @Classpath or @CompileClasspath. Please refer to https://docs.gradle.org/7.2/userguide/validation_problems.html#missing_normalization_annotation for more details about this problem. - In plugin 'com.android.build.gradle.api.AndroidBasePlugin' type 'com.android.build.gradle.internal.pipeline.TransformTask' property 'path' is missing an input or output annotation. Reason: A property without annotation isn't considered during up-to-date checking. Possible solutions: 1. Add an input or output annotation. 2. Mark it as @Internal. Please refer to https://docs.gradle.org/7.2/userguide/validation_problems.html#missing_annotation for more details about this problem. - In plugin 'com.android.build.gradle.api.AndroidBasePlugin' type 'com.android.build.gradle.internal.pipeline.TransformTask' property 'temporaryDir' is missing an input or output annotation. Reason: A property without annotation isn't considered during up-to-date checking. Possible solutions: 1. Add an input or output annotation. 2. Mark it as @Internal. Please refer to https://docs.gradle.org/7.2/userguide/validation_problems.html#missing_annotation for more details about this problem. * Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights. ============================================================================== * Get more help at https://help.gradle.org Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0. You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins. See https://docs.gradle.org/7.2/userguide/command_line_interface.html#sec:command_line_warnings BUILD FAILED in 7s |
网上搜索大部分说是把使用的gradle的版本降到原来的版本,但是因为ide升级原因?版本不能降
后来搜索到一个方法是把项目里的build.gradle中的gradle插件的版本升级一下,由原来的3.4.1版本升级到4.2.0再编译就好了
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
buildscript { repositories { google() jcenter() } dependencies { classpath 'com.android.tools.build:gradle:4.2.0' //原来是3.4.1 } } allprojects { repositories { google() jcenter() } } task clean(type: Delete) { delete rootProject.buildDir } |
出现这个问题的原因是两个表的字符集不一致
解决方法有两个:
1. 在select的时候对字段进行转码,如下:
select os.*, ob.obulatitude, ob.obulongtitude from OBU_status os left join obudevices as ob on CONVERT(os.device_ID USING utf8) COLLATE utf8_unicode_ci=ob.obuhardware
其中CONVERT(os.device_ID USING utf8) COLLATE utf8_unicode_ci使用convert函数对字段进行了转码
2. 修改表的字符集
这个比较麻烦,如果是新项目没有问题,如果是已经在运行的项目,要考虑对其他地方是不是有影响
三边长度:a, b, c
半周长:p = (a + b + c) / 2
三角形面积:S = √[p(p-a)(p-b)(p-c)] =(1/4)√[(a+b+c)(a+b-c)(a+c-b)(b+c-a)]
三边长度:a, b, c,求a到bc边的距离ad
根据上面公式得出三角形面积,
由公式S = 1/2 (底 x 高),则ad = 2*S / bc
使用subprocess的Popen函数创建了一个进程
使用Popen的kill和terminate函数都杀不掉这个进程
后来发现是因为Popen的时候使用了shell=True参数,如果不使用这个参数可以杀掉
后来百度找到了其他方法
1 2 3 4 5 6 7 |
import psutil def kill(proc_pid): process = psutil.Process(proc_pid) for proc in process.children(recursive=True): proc.kill() process.kill() |
想要杀掉进程的时候使用这个kill参数并传入子进程的pid就可以了
1 2 |
child = subprocess.Popen(['ping 192.168.1.10 -t'], shell=True, stdout=fileno, stderr=fileno) kill(child.pid) |
参考链接:http://www.dovov.com/shell-truepythonsubprocess.html
使用下面的代码读取mysql数据时出现TypeError: tuple indices must be integers or slices, not str错误
1 2 3 4 5 6 7 8 9 10 11 |
conn = pymysql.connect(host=dbhost, user=dbuser, passwd=dbpasswd, db=dbname) while True: cur = conn.cursor() cur.execute("SELECT * from radardevices where status=1") row_headers = [x[0] for x in cur.description] rows = cur.fetchall() for row in rows: print(row["macaddress"]) cur.close() time.sleep(1) conn.close() |
获取cursor时未指定cursor类型,默认使用tuple类型返回,将cur = conn.cursor()这一行修改为如下就可以了
1 |
cur = conn.cursor(cursor=pymysql.cursors.DictCursor) |
因为数据表不是通过Laravel的migration建的,所以没有updated_at字段
使用Model对象save的时候就会报上面的错误,解决方法就是在Model里增加const UPDATED_AT = null;,如下代码所示:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
<?php namespace App; use Illuminate\Database\Eloquent\Model; class AidEvent extends Model { const UPDATED_AT = null; const CREATED_AT = null; function getTable() { return "aidevents"; } } |
基本Android sdk28版本编写
设置最大录像时长(单位:毫秒),需要在setOutFormat()之后prepare()之前调用。当录像时长达到这个时长,将触发MediaRecorder.OnInfoListener事件,事件的what参数为MEDIA_RECORDER_INFO_MAX_DURATION_REACHED,并且录像停止。停止动作是异步执行的,不能保证收到OnInfoListener时停止操作已完成。
设置最大录像文件大小(单位:字节),需要在setOutFormat()之后prepare()之前调用。当录像时长达到这个时长,将触发MediaRecorder.OnInfoListener事件,事件的what参数为MEDIA_RECORDER_INFO_MAX_FILESIZE_REACHED,并且录像停止。停止动作是异步执行的,不能保证收到OnInfoListener时停止操作已完成。
当setOutputFile或者setNextOutputFile所设置的输出文件达到最大文件尺寸时,使用此函数设置下一个输出文件。文件应该是可查找的(seekable)?当设置了next output file后,程序在调用mediarecorder.stop之前不要使用这个文件。程序应该在收到what参数为MEDIA_RECORDER_INFO_MAX_FILESIZE_APPROACHING的OnInfoListener事件之后,what参数为MEDIA_RECORDER_INFO_MAX_FILESIZE_REACHED的OnInfoListener之前调用setNextOutputFile函数。当收到what参数为MEDIA_RECORDER_INFO_NEXT_OUTPUT_FILE_STARTED的OnInfoListener事件后,此函数设置的文件才开始被录制。当之前设置的文件未被使用时,是不能设置新的输出文件的。当调用stop停止录像时,程序负责清理未使用的文件。
设置一个Surface用于预览正在录制的视频。需要在prepare函数前调用此函数。
如果使用了setCamera(camera),并且camera对象已经设置了surface,程序就不用再调用此函数设置surface了,如果使用了一个非null值的surface作为参数调用了此函数,camera的预览surface将被新设置的surface代替;如果根本没有调用此函数或者传入了一个为null的surface,media recorder不会改变camera的surface。